priority_queue添加旋转
This commit is contained in:
parent
ef06a20198
commit
02cf7b9672
|
@ -864,6 +864,20 @@ 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 {
|
||||
cur = tree.lrotate3(cur)
|
||||
} else {
|
||||
cur = tree.lrrotate3(cur)
|
||||
}
|
||||
} else if cur.children[1] == nil {
|
||||
if cur.children[0].children[1] == nil {
|
||||
cur = tree.rrotate3(cur)
|
||||
} else {
|
||||
cur = tree.rlrotate3(cur)
|
||||
}
|
||||
}
|
||||
}
|
||||
cur = cur.parent
|
||||
}
|
||||
|
|
|
@ -867,15 +867,15 @@ func (tree *vbTree) fixSizeWithRemove(cur *Node) {
|
|||
} else if cur.size == 3 {
|
||||
if cur.children[0] == nil {
|
||||
if cur.children[1].children[0] == nil {
|
||||
tree.lrotate3(cur)
|
||||
cur = tree.lrotate3(cur)
|
||||
} else {
|
||||
tree.lrrotate3(cur)
|
||||
cur = tree.lrrotate3(cur)
|
||||
}
|
||||
} else if cur.children[1] == nil {
|
||||
if cur.children[0].children[1] == nil {
|
||||
tree.rrotate3(cur)
|
||||
cur = tree.rrotate3(cur)
|
||||
} else {
|
||||
tree.rlrotate3(cur)
|
||||
cur = tree.rlrotate3(cur)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user