Beispiel #1
0
        private void InsertChildNode(BPTreeNode <TKey, TData> node, TKey key, TData data)
        {
            _data[key]  = data;
            node.Parent = this;
            var keyIndex = _data.IndexOfKey(key);

            var grandChildKey = node.Data.Keys.FirstOrDefault();

            if (_comparer.Compare(grandChildKey, key) < 0)
            {
                node.MaxKey = _comparer.Decrement(key);
                if (keyIndex > 0)
                {
                    node.MinKey = _data.Keys.ElementAt(--keyIndex);
                }
                else
                {
                    node.MinKey = _comparer.MinKey;
                }
            }
            else
            {
                node.MinKey = key;
                if (keyIndex < _data.Count - 1)
                {
                    node.MaxKey = _comparer.Decrement(_data.Keys.ElementAt(++keyIndex));
                }
                else
                {
                    node.MaxKey = FindMyMaxKey(node);
                }
            }

            _children.Add(node);
            if (IsFull)
            {
                SplitNode();
            }
        }
Beispiel #2
0
 public TKey Decrement(TKey input)
 {
     return(_specificComparer.Decrement(input));
 }