Пример #1
0
        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++;
        }
Пример #2
0
 public EiLLNode(T value)
 {
     this.Value = value;
     Next       = null;
     Prev       = null;
     List       = null;
 }
Пример #3
0
 public void MoveTo(EiLinkedList <T> otherList)
 {
     List.Move(this, otherList);
 }