/// <summary>Given an item and a leaf that is known to contain a copy of /// the item, this method returns the index of the item in the tree as /// a whole. Requires O(M )</summary> protected int ReconstructIndex(T item, AListLeaf <K, T> leaf) { AListInnerBase <K, T> inner; AListNode <K, T> node; bool found; int index = leaf.IndexOf(item, 0), localIndex; if (index <= -1) { BadState(); } node = leaf; while (node != _root) { Debug.Assert(node != null); _nodes.FindLowerBoundExact(ref node, out inner, out found); if (!found) { BadState(); } if ((localIndex = (int)inner.BaseIndexOf(node)) <= -1) { BadState(); } node = inner; index += localIndex; } return(index); }
public void ItemRemoved(T item, AListLeaf <K, T> parent) { int index = _items.IndexOfExact(new KeyValuePair <T, AListLeaf <K, T> >(item, parent)); if (index <= -1) { BadState(); } _items.RemoveAt(index); }
internal static void ItemMoved <K, T>(this IAListTreeObserver <K, T> self, T item, AListLeaf <K, T> oldParent, AListLeaf <K, T> newParent) { self.ItemRemoved(item, oldParent); self.ItemAdded(item, newParent); }
internal static void RemovingItems <K, T>(this IAListTreeObserver <K, T> self, InternalDList <T> list, int index, int count, AListLeaf <K, T> parent, bool isMoving) { for (int i = index; i < index + count; i++) { self.ItemRemoved(list[i], parent); } }
internal static void AddingItems <K, T>(this IAListTreeObserver <K, T> self, IListSource <T> list, AListLeaf <K, T> parent, bool isMoving) { for (int i = 0; i < list.Count; i++) { self.ItemAdded(list[i], parent); } }
public void ItemAdded(T item, AListLeaf <K, T> parent) { _items.Add(new KeyValuePair <T, AListLeaf <K, T> >(item, parent)); }
internal static void ItemsMoved <K, T>(this IAListTreeObserver <K, T> self, InternalList <T> list, int index, int count, AListLeaf <K, T> oldParent, AListLeaf <K, T> newParent) { for (int i = index; i < index + count; i++) { self.ItemMoved(list[i], oldParent, newParent); } }
public AListLeaf(AListLeaf <K, T> original) { _list = original._list.Clone(); _maxNodeSize = original._maxNodeSize; _isFrozen = false; }