/// <summary>
        /// 将旧的根节点分割,新的根节点将有两个子节点
        /// </summary>
        /// <param name="oldRoot">原根节点</param>
        /// <param name="splitFirstKey">新根节点的第一个键</param>
        /// <param name="splitNode">新分割出的节点</param>
        /// <param name="tree">指定的树</param>
        /// <returns>新根节点</returns>
        public static BPlusTreeNode BinaryRoot(
            BPlusTreeNode oldRoot, string splitFirstKey,
            BPlusTreeNode splitNode, BPlusTree tree)
        {
            if (oldRoot == null)
            {
                throw new ArgumentNullException("oldRoot");
            }
            if (splitNode == null)
            {
                throw new ArgumentNullException("splitNode");
            }

            // 已不是叶节点
            BPlusTreeNode newRoot = MakeRoot(tree, false);

            // 新的跟记录分割节点的第一个键
            newRoot._childKeys[0] = splitFirstKey;

            // 新旧节点分别为新的根节点的索引 0 1 位置
            oldRoot.ResetParent(newRoot, 0);
            splitNode.ResetParent(newRoot, 1);

            return(newRoot);
        }
 /// <summary>
 /// 重置所有子节点的父节点
 /// </summary>
 private void ResetAllChildrenParent()
 {
     for (int i = 0; i <= this.Capacity; i++)
     {
         BPlusTreeNode node = this._childNodes[i];
         if (node != null)
         {
             node.ResetParent(this, i);
         }
     }
 }
Esempio n. 3
0
        public static BPlusTreeNode BinaryRoot(
            BPlusTreeNode oldRoot, string splitFirstKey,
            BPlusTreeNode splitNode, BPlusTree tree)
        {
            if (oldRoot == null)
            {
                throw new ArgumentNullException("oldRoot");
            }
            if (splitNode == null)
            {
                throw new ArgumentNullException("splitNode");
            }

            BPlusTreeNode newRoot = MakeRoot(tree, false);

            newRoot._childKeys[0] = splitFirstKey;

            oldRoot.ResetParent(newRoot, 0);
            splitNode.ResetParent(newRoot, 1);

            return(newRoot);
        }