Fixed AVLTrees pollFirst/pollLast
This commit is contained in:
+2
-7
@@ -767,11 +767,11 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
entry.value = successor.value;
|
||||
entry = successor;
|
||||
}
|
||||
if(entry.previous() == null) first = entry.next();
|
||||
if(entry.next() == null) last = entry.previous();
|
||||
Entry KEY_VALUE_GENERIC_TYPE replacement = entry.left != null ? entry.left : entry.right;
|
||||
if(replacement != null) {
|
||||
if(entry.replace(replacement)) tree = replacement;
|
||||
if(entry == first) first = replacement;
|
||||
if(entry == last) last = entry.right != null ? entry.right : replacement;
|
||||
entry.left = entry.right = entry.parent = null;
|
||||
fixAfterDeletion(replacement);
|
||||
}
|
||||
@@ -779,11 +779,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
else {
|
||||
fixAfterDeletion(entry);
|
||||
entry.replace(null);
|
||||
if(entry.parent != null) {
|
||||
Entry KEY_VALUE_GENERIC_TYPE parent = entry.parent;
|
||||
if(entry == first) first = parent.left != null ? parent.left : parent;
|
||||
if(entry == last) last = entry.right != null ? parent.right : parent;
|
||||
}
|
||||
entry.parent = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user