Example #1
0
        public void Remove_InsideOfTree_UpdatesParents()
        {
            CreateThreeLevelTree(1);
            _target.Remove(_leaves[2]);

            Assert.AreEqual(1, _leaves[1].Above.ItemsInNode);
            Assert.AreEqual(4, _headers[0].ItemsInNode);

            AssertLinked(_leaves[1], _leaves[3]);
            AssertLinked(_leaves[1].Above, _leaves[3].Above);
        }
        private void RemoveItem(IndexingSkipList <IList <TResult> > .Node node, TSource item, IList <TResult> collection)
        {
            _collectionIndex.Remove(node);

            int numberOfInstancesOfCollectionLeft = RemoveNodeFromLookupTable(_collectionToNode, collection, node);

            RemoveNodeFromLookupTable(_sourceToCollectionNode, item, node);

            if (collection != null && numberOfInstancesOfCollectionLeft == 0)
            {
                var handler = _weakEventHandlers[collection];
                handler.Deregister();
                _weakEventHandlers.Remove(collection);
            }
        }