void CreateNode(Node <T> dad, T newValue, bool headLeft) { MultiPathNode <T> newNode = new MultiPathNode <T>(degree); newNode.Enlist(newValue); if (headLeft) { dad.LeftChild = newNode; } else { dad.RightChild = newNode; } }
bool RecursiveInsert(T value, MultiPathNode <T> SubTree) { if (!SubTree.IsFull()) { SubTree.Enlist(value); return(true); } else { Node <T> aux = new Node <T>(); aux = SubTree.PeekNode(value); if (aux != null) { if (aux.prev == null && value.CompareTo(aux.t_object) < 0) { if (aux.LeftChild != null) { return(RecursiveInsert(value, aux.LeftChild)); } else { CreateNode(aux, value, true); return(true); } } else { if (aux.RightChild != null) { return(RecursiveInsert(value, aux.RightChild)); } else { CreateNode(aux, value, false); return(true); } } } else { return(false); } } }
public bool Insert(T value) { if (!Root.IsFull()) { Root.Enlist(value); return(true); } else { Node <T> aux = new Node <T>(); aux = Root.PeekNode(value); if (aux != null) { if (aux.prev == null && value.CompareTo(aux.t_object) < 0) { if (aux.LeftChild != null) { return(RecursiveInsert(value, aux.LeftChild)); } else { CreateNode(aux, value, true); return(true); } } else { if (aux.RightChild != null) { return(RecursiveInsert(value, aux.RightChild)); } else { CreateNode(aux, value, false); return(true); } } } else { return(false); } } }