Esempio n. 1
0
        private void SplitNode()
        {
            var splitIndex = (BranchingFactor - 1) / 2;
            var left       = this;
            var right      = new BPTreeNode <TKey, TData>(BranchingFactor);

            var splitElem = _data.ElementAt(splitIndex);

            left.MaxKey = _comparer.Decrement(splitElem.Key);

            for (int i = _data.Count - 1; i > splitIndex; i--)
            {
                var elem = _data.ElementAt(i);
                right.Insert(elem.Key, elem.Value);
                _data.RemoveAt(i);
            }
            _data.RemoveAt(splitIndex);

            foreach (var child in _children.Where(c => _comparer.Compare(c.MinKey, splitElem.Key) >= 0).ToList())
            {
                right.Children.Add(child);
                child.Parent = right;
                _children.Remove(child);
            }

            if (this.Parent == null)
            {
                this.Parent = new BPTreeNode <TKey, TData>(BranchingFactor);
                this.Parent.InsertChildNode(left, splitElem.Key, splitElem.Value);
            }
            Parent.InsertChildNode(right, splitElem.Key, splitElem.Value);
        }
Esempio n. 2
0
 public void Insert(DataKey key, DataItem value)
 {
     _indexTree = _indexTree.Insert(key.GetKey <TKey>(), value);
 }