From ef6c52294b50a2a1ba6552ad4c08274f4499d0ec Mon Sep 17 00:00:00 2001 From: huangsimin Date: Mon, 23 Mar 2020 10:56:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=8A=E4=B8=80=E4=BA=9B=E8=BF=90=E7=AE=97?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=BA=E4=BD=8D=E8=BF=90=E7=AE=97.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- priority_queue/vbt.go | 8 ++++---- priority_queuekey/vbtkey.go | 8 ++++---- tree/lsv/dtree.go | 8 ++++---- tree/lsv/itree.go | 8 ++++---- tree/vbt/vbt.go | 8 ++++---- tree/vbtdup/vbtdup.go | 8 ++++---- tree/vbtkey/vbtkey.go | 8 ++++---- tree/vbtkeydup/vbtdupkey.go | 8 ++++---- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/priority_queue/vbt.go b/priority_queue/vbt.go index 6ed7209..78179d9 100644 --- a/priority_queue/vbt.go +++ b/priority_queue/vbt.go @@ -451,9 +451,9 @@ func (tree *vbTree) Put(key interface{}) { for cur := tree.root; ; { if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := cur.children[0].size, cur.children[1].size - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { cur = tree.fixSize(cur, ls, rs) } } @@ -861,9 +861,9 @@ func (tree *vbTree) fixSizeWithRemove(cur *Node) { for cur != nil { cur.size-- if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := getChildrenSize(cur) - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { cur = tree.fixSize(cur, ls, rs) } } else if cur.size == 3 { diff --git a/priority_queuekey/vbtkey.go b/priority_queuekey/vbtkey.go index faf4217..292f4f5 100644 --- a/priority_queuekey/vbtkey.go +++ b/priority_queuekey/vbtkey.go @@ -451,9 +451,9 @@ func (tree *vbTree) Put(key, value interface{}) { for cur := tree.root; ; { if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := cur.children[0].size, cur.children[1].size - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { cur = tree.fixSize(cur, ls, rs) } } @@ -861,9 +861,9 @@ func (tree *vbTree) fixSizeWithRemove(cur *Node) { for cur != nil { cur.size-- if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := getChildrenSize(cur) - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { cur = tree.fixSize(cur, ls, rs) } } else if cur.size == 3 { diff --git a/tree/lsv/dtree.go b/tree/lsv/dtree.go index 35540a4..92e855a 100644 --- a/tree/lsv/dtree.go +++ b/tree/lsv/dtree.go @@ -513,9 +513,9 @@ func (tree *DTree) Put(key, value []rune) (isInsert bool) { for cur := tree.root; ; { if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := cur.family[1].size, cur.family[2].size - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { tree.fixSize(cur, ls, rs) } } @@ -970,9 +970,9 @@ func (tree *DTree) fixSizeWithRemove(cur *DNode) { for cur != nil { cur.size-- if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := getChildrenSize(cur) - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { tree.fixSize(cur, ls, rs) } } else if cur.size == 3 { diff --git a/tree/lsv/itree.go b/tree/lsv/itree.go index d0825a4..d544ae3 100644 --- a/tree/lsv/itree.go +++ b/tree/lsv/itree.go @@ -41,9 +41,9 @@ func (tree *ITree) Put(key, value []rune) (isInsert bool) { for cur := tree.root; ; { if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := cur.family[1].size, cur.family[2].size - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { tree.ifixSize(cur, ls, rs) } } @@ -433,9 +433,9 @@ func (tree *ITree) ifixSizeWithRemove(cur *INode) { for cur != nil { cur.size-- if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := igetChildrenSize(cur) - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { tree.ifixSize(cur, ls, rs) } } else if cur.size == 3 { diff --git a/tree/vbt/vbt.go b/tree/vbt/vbt.go index df80f91..0beec47 100644 --- a/tree/vbt/vbt.go +++ b/tree/vbt/vbt.go @@ -443,9 +443,9 @@ func (tree *Tree) Put(key interface{}) { for cur := tree.root; ; { if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := cur.children[0].size, cur.children[1].size - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { tree.fixSize(cur, ls, rs) } } @@ -874,9 +874,9 @@ func (tree *Tree) fixSizeWithRemove(cur *Node) { for cur != nil { cur.size-- if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := getChildrenSize(cur) - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { tree.fixSize(cur, ls, rs) } } else if cur.size == 3 { diff --git a/tree/vbtdup/vbtdup.go b/tree/vbtdup/vbtdup.go index fa7fe6a..469a35b 100644 --- a/tree/vbtdup/vbtdup.go +++ b/tree/vbtdup/vbtdup.go @@ -445,9 +445,9 @@ func (tree *Tree) Put(value interface{}) (isInsert bool) { for cur := tree.root; ; { if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := cur.children[0].size, cur.children[1].size - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { tree.fixSize(cur, ls, rs) } } @@ -895,9 +895,9 @@ func (tree *Tree) fixSizeWithRemove(cur *Node) { for cur != nil { cur.size-- if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := getChildrenSize(cur) - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { tree.fixSize(cur, ls, rs) } } else if cur.size == 3 { diff --git a/tree/vbtkey/vbtkey.go b/tree/vbtkey/vbtkey.go index d319995..f545760 100644 --- a/tree/vbtkey/vbtkey.go +++ b/tree/vbtkey/vbtkey.go @@ -446,9 +446,9 @@ func (tree *Tree) Put(key, value interface{}) { for cur := tree.root; ; { if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := cur.children[0].size, cur.children[1].size - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { tree.fixSize(cur, ls, rs) } } @@ -884,9 +884,9 @@ func (tree *Tree) fixSizeWithRemove(cur *Node) { for cur != nil { cur.size-- if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := getChildrenSize(cur) - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { tree.fixSize(cur, ls, rs) } } else if cur.size == 3 { diff --git a/tree/vbtkeydup/vbtdupkey.go b/tree/vbtkeydup/vbtdupkey.go index 51cfbd8..7e3da43 100644 --- a/tree/vbtkeydup/vbtdupkey.go +++ b/tree/vbtkeydup/vbtdupkey.go @@ -446,9 +446,9 @@ func (tree *Tree) Put(key, value interface{}) (isInsert bool) { for cur := tree.root; ; { if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := cur.children[0].size, cur.children[1].size - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { tree.fixSize(cur, ls, rs) } } @@ -896,9 +896,9 @@ func (tree *Tree) fixSizeWithRemove(cur *Node) { for cur != nil { cur.size-- if cur.size > 8 { - factor := cur.size / 10 // or factor = 1 + factor := cur.size >> 3 // or factor = 1 ls, rs := getChildrenSize(cur) - if rs >= ls*2+factor || ls >= rs*2+factor { + if rs >= (ls<<1)+factor || ls >= (rs<<1)+factor { tree.fixSize(cur, ls, rs) } } else if cur.size == 3 {