Пример #1
0
 public void AddAfter(DoublyNodeLinkedListNode <T> current, DoublyNodeLinkedListNode <T> newNode)
 {
     newNode.Next      = current.Next;
     current.Next.Prev = newNode;
     newNode.Prev      = current;
     current.Next      = newNode;
 }
Пример #2
0
 public DoublyNodeLinkedListNode
     (T data,
     DoublyNodeLinkedListNode <T> prev = null,
     DoublyNodeLinkedListNode <T> next = null)
 {
     this.Data = data;
     this.Prev = prev;
     this.Next = next;
 }
Пример #3
0
            //Add
            //AddAfter
            //GetIndex

            public void Add(DoublyNodeLinkedListNode <T> newNode)
            {
                if (_head is null)
                {
                    _head      = newNode;
                    _head.Prev = _head;
                    _head.Next = _head;
                }
                else
                {
                    var current = _head;

                    var tail = current.Prev;

                    current.Prev = newNode;
                    tail.Next    = newNode;
                    newNode.Prev = tail;
                    newNode.Next = current;
                }
            }