diff --git a/priority_queuekey/vbt.go b/priority_queuekey/vbt.go index fd351b5..a5d45f6 100644 --- a/priority_queuekey/vbt.go +++ b/priority_queuekey/vbt.go @@ -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 } } diff --git a/vbt/vbt.go b/vbt/vbt.go index 4ce84c7..207f136 100644 --- a/vbt/vbt.go +++ b/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 } diff --git a/vbtkey/vbtkey.go b/vbtkey/vbtkey.go index 18da20b..fb48e2b 100644 --- a/vbtkey/vbtkey.go +++ b/vbtkey/vbtkey.go @@ -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 }