public Node RemoveEnd() { Node oldTail = _tail; if (_tail == null) // no nodes { return(null); } else if (_head == _tail) //one node { _head = null; _tail = null; } else //two or more nodes { Node secondLast = _tail.Parent; _tail = secondLast; _tail.SetChild(null); } Size--; oldTail.SetChild(null); oldTail.SetParent(null); return(oldTail); }
private void InsertAtHead(Node n) { n.SetParent(null); n.SetChild(_head); if (_head == null) // no nodes yet { Debug.Assert(_tail == null); _tail = n; } if (_head != null) // at least one node in the list { _head.SetParent(n); } _head = n; }
public void SetParentTest() { Node parent = new Node(null, null, new Element(new byte[0]), 0); Node n = new Node(null, null, new Element(new byte[0]), 1); n.SetParent(parent); Assert.AreEqual(parent, n.Parent); }