示例#1
0
        /// <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, AListLeafBase <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);
        }
示例#2
0
        public void ItemRemoved(T item, AListLeafBase <K, T> parent)
        {
            int index = _items.IndexOfExact(new KeyValuePair <T, AListLeafBase <K, T> >(item, parent));

            if (index <= -1)
            {
                BadState();
            }
            _items.RemoveAt(index);
        }
示例#3
0
 public void ItemAdded(T item, AListLeafBase <K, T> parent)
 {
     _items.Add(new KeyValuePair <T, AListLeafBase <K, T> >(item, parent));
 }