Make ZCC_TreeNode::AppendSibling() work with lists

- Previously, you could only append lone nodes to ZCC_TreeNode lists.
  Now you can append one list to another.
This commit is contained in:
Randy Heit 2013-09-12 21:58:06 -05:00
parent 2ab3974752
commit d5fa550118

View file

@ -211,17 +211,19 @@ struct ZCC_TreeNode
return; return;
} }
// The new sibling node should only be in a list with itself.
assert(sibling->SiblingNext == sibling && sibling->SiblingPrev == sibling);
// Check integrity of our sibling list. // Check integrity of our sibling list.
assert(SiblingPrev->SiblingNext == this); assert(SiblingPrev->SiblingNext == this);
assert(SiblingNext->SiblingPrev == this); assert(SiblingNext->SiblingPrev == this);
// Check integrity of new sibling list.
assert(sibling->SiblingPrev->SiblingNext = sibling);
assert(sibling->SiblingNext->SiblingPrev = sibling);
ZCC_TreeNode *siblingend = sibling->SiblingPrev;
SiblingPrev->SiblingNext = sibling; SiblingPrev->SiblingNext = sibling;
sibling->SiblingPrev = SiblingPrev; sibling->SiblingPrev = SiblingPrev;
SiblingPrev = sibling; SiblingPrev = siblingend;
sibling->SiblingNext = this; siblingend->SiblingNext = this;
} }
}; };