public void AddNodeToFront(T value)
 {
     if (Head == null)
     {
         Head      = new DoublyLinkedListNode <T>(value);
         Tail      = Head;
         Head.prev = Tail;
         Tail.next = Head;
     }
     else
     {
         DoublyLinkedListNode <T> current = new DoublyLinkedListNode <T>(value);
         Head.prev    = null;
         Head.prev    = current;
         current.next = Head;
         Head         = current;
         Head.prev    = Tail;
         Tail.next    = Head;
     }
     Count++;
 }
 public bool RemoveLast()
 {
     if (Head == null)
     {
         return(false);
     }
     else
     {
         if (Head == Tail)
         {
             Clear();
             return(true);
         }
         else
         {
             Tail.next = null;
             Tail      = Tail.prev;
             Tail.next = null;
             Tail.next = Head;
         }
         Count--;
         return(true);
     }
 }
 public void Clear()
 {
     Head  = null;
     Tail  = null;
     Count = 0;
 }
Beispiel #4
0
 public DoublyLinkedListNode(T current)
 {
     data = current;
     next = null;
     prev = null;
 }