vbt添加了 size = 3 时候的旋转
This commit is contained in:
parent
3536347a88
commit
ef06a20198
|
@ -864,7 +864,22 @@ func (tree *vbTree) fixSizeWithRemove(cur *Node) {
|
|||
if rs >= ls*2+factor || ls >= rs*2+factor {
|
||||
cur = tree.fixSize(cur, ls, rs)
|
||||
}
|
||||
} else if cur.size == 3 {
|
||||
if cur.children[0] == nil {
|
||||
if cur.children[1].children[0] == nil {
|
||||
tree.lrotate3(cur)
|
||||
} else {
|
||||
tree.lrrotate3(cur)
|
||||
}
|
||||
} else if cur.children[1] == nil {
|
||||
if cur.children[0].children[1] == nil {
|
||||
tree.rrotate3(cur)
|
||||
} else {
|
||||
tree.rlrotate3(cur)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur = cur.parent
|
||||
}
|
||||
}
|
||||
|
|
14
vbt/vbt.go
14
vbt/vbt.go
|
@ -868,6 +868,20 @@ func (tree *Tree) fixSizeWithRemove(cur *Node) {
|
|||
if rs >= ls*2+factor || ls >= rs*2+factor {
|
||||
tree.fixSize(cur, ls, rs)
|
||||
}
|
||||
} else if cur.size == 3 {
|
||||
if cur.children[0] == nil {
|
||||
if cur.children[1].children[0] == nil {
|
||||
tree.lrotate3(cur)
|
||||
} else {
|
||||
tree.lrrotate3(cur)
|
||||
}
|
||||
} else if cur.children[1] == nil {
|
||||
if cur.children[0].children[1] == nil {
|
||||
tree.rrotate3(cur)
|
||||
} else {
|
||||
tree.rlrotate3(cur)
|
||||
}
|
||||
}
|
||||
}
|
||||
cur = cur.parent
|
||||
}
|
||||
|
|
|
@ -877,6 +877,20 @@ func (tree *Tree) fixSizeWithRemove(cur *Node) {
|
|||
if rs >= ls*2+factor || ls >= rs*2+factor {
|
||||
tree.fixSize(cur, ls, rs)
|
||||
}
|
||||
} else if cur.size == 3 {
|
||||
if cur.children[0] == nil {
|
||||
if cur.children[1].children[0] == nil {
|
||||
tree.lrotate3(cur)
|
||||
} else {
|
||||
tree.lrrotate3(cur)
|
||||
}
|
||||
} else if cur.children[1] == nil {
|
||||
if cur.children[0].children[1] == nil {
|
||||
tree.rrotate3(cur)
|
||||
} else {
|
||||
tree.rlrotate3(cur)
|
||||
}
|
||||
}
|
||||
}
|
||||
cur = cur.parent
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user