Пример #1
0
        public void Update(IKeyNode keyNode, T instance)
        {
            var value = _getter(instance);

            var node = (DataNode <K>)keyNode[this];

            if (node != null)
            {
                Debug.Assert(node.Keys.Contains(keyNode));

                if (_tree.Comparer.Compare(value, node.Key) == 0)
                {
                    return;
                }

                node.Keys.Remove(keyNode);
                if (node.Keys.Count == 0)
                {
                    _tree.Remove(node);
                }
            }

            node = _tree.AddOrGet(value);
            node.Keys.Add(keyNode);
            keyNode[this] = node;
        }
Пример #2
0
        public bool RemoveByKey(K key)
        {
            var node = _tree.Find(key);

            if (node == null)
            {
                return(false);
            }

            _tree.Remove(node);
            _map.Free(node);

            node.Clean();

            return(true);
        }