public InterNalNode(InterNalNode node) { this.Value = node.Value; this.RecordKey = node.RecordKey; this.LeftNode = node.LeftNode; this.RightNode = node.RightNode; }
public void Insert(int value, string recordKey) { InterNalNode newInternalNode = new InterNalNode() { RecordKey = recordKey, Value = value, LeftNode = null, RightNode = null }; if (IsEmpty()) { Node newNode = new Node(); newNode.InternalNodes.Add(newInternalNode); this.RootNode = newNode; this.Nodes.Add(newNode); } else { //bool IsInserted = false; Node target = Search(value); if (!target.IsFull()) { target.InternalNodes.Add(newInternalNode); target.Sort(); } else { Split(target, value, recordKey); } } }
void SplitRoot(Node root, InterNalNode insertedNode) { Node newLeafLeft = new Node(); Node newLeafRight = new Node(); Node newRoot = new Node(); root.InternalNodes.Add(insertedNode); root.Sort(); newLeafLeft.InternalNodes.Add(new InterNalNode(root.InternalNodes[0])); newLeafLeft.InternalNodes.Add(new InterNalNode(root.InternalNodes[1])); newLeafRight.InternalNodes.Add(new InterNalNode(root.InternalNodes[2])); newLeafRight.InternalNodes.Add(new InterNalNode(root.InternalNodes[3])); newLeafLeft.ParentNode = newRoot; newLeafRight.ParentNode = newRoot; newRoot.InternalNodes.Add(new InterNalNode(root.InternalNodes[1].Value, root.InternalNodes[1].RecordKey)); newRoot.InternalNodes[0].LeftNode = newLeafLeft; newRoot.InternalNodes[0].RightNode = newLeafRight; this.Nodes.Remove(root); this.RootNode = newRoot; this.Nodes.Add(newRoot); this.Nodes.Add(newLeafLeft); this.Nodes.Add(newLeafRight); }
public Node GoRight(InterNalNode node) { return(node.RightNode); }
public Node GoLeft(InterNalNode node) { return(node.LeftNode); }