public void Move(EiLLNode <T> node, EiLinkedList <T> otherList) { if (node.List != this) { throw new Exception("You are not allowed to move nodes from other list without going through its own list"); } if (count == 1) { this.node = null; } node.Prev.Next = node.Next; node.Next.Prev = node.Prev; node.List = otherList; if (otherList.Count() == 0) { node.Next = node; node.Prev = node; otherList.node = node; } else { otherList.node.Prev.Next = node; node.Prev = otherList.node.Prev; node.Next = otherList.node; otherList.node.Prev = node; } count--; otherList.count++; }
public EiLLNode(T value) { this.Value = value; Next = null; Prev = null; List = null; }
public void MoveTo(EiLinkedList <T> otherList) { List.Move(this, otherList); }