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 {