internal override uint TakeFromRight(AListNode <K, T> sibling, int localsToMove, IAListTreeObserver <K, T> tob) { Debug.Assert(localsToMove <= sibling.LocalCount && LocalCount + localsToMove <= _maxNodeSize); var right = (AListInnerBase <K, T>)sibling; if (_isFrozen || right._isFrozen) { return(0); } uint totalCountMoved = 0; for (int i = 0; i < localsToMove; i++) { uint oldTotal = TotalCount; int oldLocal = LocalCount; var child = right.Child(0); LLInsert(oldLocal, child, 0); Debug.Assert(oldLocal > 0); Debug.Assert(child.TotalCount > 0); _children[oldLocal].Index = oldTotal; right.LLDelete(0, true); AssertValid(); right.AssertValid(); if (tob != null) { tob.NodeMoved(child, right, this); } totalCountMoved += child.TotalCount; } return(totalCountMoved); }
internal override uint TakeFromLeft(AListNode <K, T> sibling, int localsToMove, IAListTreeObserver <K, T> tob) { Debug.Assert(!IsFrozen); var left = (AListInnerBase <K, T>)sibling; if (IsFrozen || left.IsFrozen) { return(0); } uint totalCountMoved = 0; for (int i = 0; i < localsToMove; i++) { var child = left.Child(left.LocalCount - 1); LLInsert(0, child, child.TotalCount); Debug.Assert(child.TotalCount > 0); left.LLDelete(left.LocalCount - 1, false); AssertValid(); left.AssertValid(); if (tob != null) { tob.NodeMoved(child, left, this); } totalCountMoved += child.TotalCount; } return(totalCountMoved); }
internal override uint TakeFromRight(AListNode <K, T> sibling, IAListTreeObserver <K, T> tob) { var right = (AListInnerBase <K, T>)sibling; if (IsFrozen || right.IsFrozen) { return(0); } uint oldTotal = TotalCount; int oldLocal = LocalCount; var child = right.Child(0); LLInsert(oldLocal, child, 0); Debug.Assert(oldLocal > 0); Debug.Assert(child.TotalCount > 0); _children[oldLocal].Index = oldTotal; right.LLDelete(0, true); AssertValid(); right.AssertValid(); if (tob != null) { tob.NodeMoved(child, right, this); } return(child.TotalCount); }