public void RemoveNode(Node node) { switch (Mode) { case TreeBehaviour.Cyclic: var source = new Queue <Node>(); source.Enqueue(node); while (source.Count != 0) { var nodeCurrent = source.Dequeue(); // remove the current node from the base list Nodes.Remove(nodeCurrent); // remove the current node from the parent's childs list nodeCurrent.Parent.Childs.Remove(nodeCurrent); // add childs of the current node to the deletion queue source.EnqueueBatch(nodeCurrent.Childs); DelBuffer.Enqueue(nodeCurrent); } break; case TreeBehaviour.Recursive: RemoveNodeRecursive(node); break; } }
public void RemoveNode(Node node) { // remove the current node from the base list Nodes.Remove(node); // remove the current node from the child's parent node.Child.Parent = node.Parent; // remove the current node from the parent's child node.Parent.Child = node.Child; DelBuffer.Enqueue(node); }
public void RemoveNodeRecursive(Node node) { // remove the node from the base list Nodes.Remove(node); // remove the node from the parent's childs list node.Parent.Childs.Remove(node); // remove all childs of the node var childs = new List <Node>(node.Childs); foreach (var child in childs) { RemoveNodeRecursive(child); } DelBuffer.Enqueue(node); }