void NewRoot(T _newValue, int BrotherID) { RootID = AvailableID; DiskBNode <T> AuxNode = new DiskBNode <T>(delegate_toT, ValueLength, Degree); AuxNode.CreateNode(AvailableID, 0); AuxNode.Insert(_newValue); AuxNode.BNodeSons.Push(BrotherID); AuxNode.BNodeSons.Push(ActualID); Stack <int> AuxStack = new Stack <int>(); int count = AuxNode.BNodeSons.Count; for (int i = 0; i < count; i++) { if (AuxNode.BNodeSons.Peek() != 0) { SonsUpdate(AuxNode.BNodeSons.Peek(), AuxNode.ID); AuxStack.Push(AuxNode.BNodeSons.Pop()); } } count = AuxStack.Count; for (int i = 0; i < count; i++) { AuxNode.BNodeSons.Push(AuxStack.Pop()); } WriteNode(RootID, AuxNode.ToFixedLengthText()); AvailableID++; }
void DivideNode() { DiskBNode <T> BrotherNode = new DiskBNode <T>(delegate_toT, ValueLength, Degree); BrotherNode.CreateNode(AvailableID, ParentID); AvailableID++; int count = GreatestSons.Count; for (int i = 0; i < count; i++) { BrotherNode.BNodeSons.Push(GreatestSons.Pop()); } count = GreatestValues.Count; for (int i = 0; i < count; i++) { BrotherNode.BNodeValues.Enlist(GreatestValues.Pop()); } WriteNode(BrotherNode.ID, BrotherNode.ToFixedLengthText()); ParentUpdate(BrotherNode.ID); }