Ejemplo n.º 1
0
        private void ShareLeafValue(BLeaf leftLeaf, BLeaf rightLeaf)
        {
            int value = 0;

            if (leftLeaf.GetMinKey() < rightLeaf.GetMinKey())
            {
                int i = leftLeaf.GetChildrenNum() - 1;
                value = leftLeaf.Values[i];
            }
            else
            {
                value = leftLeaf.GetMinKey();
            }
            rightLeaf.AddValue(value);
            leftLeaf.RemoveValue(value);
        }
Ejemplo n.º 2
0
        private void MergeLeaf(BLeaf leftLeaf, BLeaf rightLeaf)
        {
            BLeaf newLeaf = new BLeaf(M);

            //位置调换一下
            if (leftLeaf.GetMinKey() > rightLeaf.GetMinKey())
            {
                var temp = leftLeaf;
                leftLeaf  = rightLeaf;
                rightLeaf = temp;
            }
            var list = leftLeaf.Values;

            list.AddRange(rightLeaf.Values);
            leftLeaf.Values   = list;
            leftLeaf.NextLeaf = rightLeaf.NextLeaf;
            var parent = leftLeaf.Parent;

            parent.RemoveChildren(rightLeaf);
        }