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 {
|
if rs >= ls*2+factor || ls >= rs*2+factor {
|
||||||
cur = tree.fixSize(cur, ls, rs)
|
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
|
cur = cur.parent
|
||||||
}
|
}
|
||||||
|
|
|
@ -867,15 +867,15 @@ func (tree *vbTree) fixSizeWithRemove(cur *Node) {
|
||||||
} else if cur.size == 3 {
|
} else if cur.size == 3 {
|
||||||
if cur.children[0] == nil {
|
if cur.children[0] == nil {
|
||||||
if cur.children[1].children[0] == nil {
|
if cur.children[1].children[0] == nil {
|
||||||
tree.lrotate3(cur)
|
cur = tree.lrotate3(cur)
|
||||||
} else {
|
} else {
|
||||||
tree.lrrotate3(cur)
|
cur = tree.lrrotate3(cur)
|
||||||
}
|
}
|
||||||
} else if cur.children[1] == nil {
|
} else if cur.children[1] == nil {
|
||||||
if cur.children[0].children[1] == nil {
|
if cur.children[0].children[1] == nil {
|
||||||
tree.rrotate3(cur)
|
cur = tree.rrotate3(cur)
|
||||||
} else {
|
} else {
|
||||||
tree.rlrotate3(cur)
|
cur = tree.rlrotate3(cur)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user