fix backwards logic in treeMapInsert which prevented correct balancing

This commit is contained in:
Joel Dice 2008-11-22 14:14:52 -07:00
parent 15ea90cd0c
commit 2e2925c321

View File

@ -143,7 +143,7 @@ treeAdd(Thread* t, object path)
if (treeNodeRed if (treeNodeRed
(t, treeNodeRight(t, pairFirst(t, pairSecond(t, ancestors))))) (t, treeNodeRight(t, pairFirst(t, pairSecond(t, ancestors)))))
{ {
setTreeNodeRed(t, pairFirst(t, ancestors), true); setTreeNodeRed(t, pairFirst(t, ancestors), false);
object n = cloneTreeNode object n = cloneTreeNode
(t, treeNodeRight(t, pairFirst(t, pairSecond(t, ancestors)))); (t, treeNodeRight(t, pairFirst(t, pairSecond(t, ancestors))));
@ -154,7 +154,7 @@ treeAdd(Thread* t, object path)
(t, treeNodeRight (t, treeNodeRight
(t, pairFirst(t, pairSecond(t, ancestors))), false); (t, pairFirst(t, pairSecond(t, ancestors))), false);
setTreeNodeRed(t, pairFirst(t, pairSecond(t, ancestors)), false); setTreeNodeRed(t, pairFirst(t, pairSecond(t, ancestors)), true);
new_ = pairFirst(t, pairSecond(t, ancestors)); new_ = pairFirst(t, pairSecond(t, ancestors));
ancestors = pairSecond(t, pairSecond(t, ancestors)); ancestors = pairSecond(t, pairSecond(t, ancestors));
@ -195,7 +195,7 @@ treeAdd(Thread* t, object path)
if (treeNodeRed if (treeNodeRed
(t, treeNodeLeft(t, pairFirst(t, pairSecond(t, ancestors))))) (t, treeNodeLeft(t, pairFirst(t, pairSecond(t, ancestors)))))
{ {
setTreeNodeRed(t, pairFirst(t, ancestors), true); setTreeNodeRed(t, pairFirst(t, ancestors), false);
object n = cloneTreeNode object n = cloneTreeNode
(t, treeNodeLeft(t, pairFirst(t, pairSecond(t, ancestors)))); (t, treeNodeLeft(t, pairFirst(t, pairSecond(t, ancestors))));
@ -206,7 +206,7 @@ treeAdd(Thread* t, object path)
(t, treeNodeLeft (t, treeNodeLeft
(t, pairFirst(t, pairSecond(t, ancestors))), false); (t, pairFirst(t, pairSecond(t, ancestors))), false);
setTreeNodeRed(t, pairFirst(t, pairSecond(t, ancestors)), false); setTreeNodeRed(t, pairFirst(t, pairSecond(t, ancestors)), true);
new_ = pairFirst(t, pairSecond(t, ancestors)); new_ = pairFirst(t, pairSecond(t, ancestors));
ancestors = pairSecond(t, pairSecond(t, ancestors)); ancestors = pairSecond(t, pairSecond(t, ancestors));