public bool Contains(T item)
        {
            DoubleLinkedListNode <T> current = Head;

            while (current != null)
            {
                if (current.Value.Equals(item))
                {
                    return(true);
                }
                current = current.Next;
            }
            return(false);
        }
 public void RemoveFirst()
 {
     if (Count != 0)
     {
         Head = Head.Next;
         Count--;
         if (Count == 0)
         {
             Tail = null;
         }
         else
         {
             Head.Previous = null;
         }
     }
 }
        public void AddLast(DoubleLinkedListNode <T> node)
        {
            node.Next = null;

            if (Count == 0)
            {
                Head = node;
            }
            else
            {
                Tail.Next     = node;
                node.Previous = Tail;
            }
            Tail = node;
            Count++;
        }
 public void RemoveLast()
 {
     if (Count != 0)
     {
         if (Count == 1)
         {
             Head = null;
             Tail = null;
         }
         else
         {
             Tail.Previous.Next = null;
             Tail = Tail.Previous;
         }
         Count--;
     }
 }
        public void AddFirst(DoubleLinkedListNode <T> node)
        {
            DoubleLinkedListNode <T> temp = Head;

            Head      = node;
            Head.Next = temp;

            if (Count == 0)
            {
                Tail = Head;
            }
            else
            {
                temp.Previous = Head;
            }
            Count++;
        }
Esempio n. 6
0
 public void AddFirst(T item)
 {
     if (item != null)
     {
         var tmp = new DoubleLinkedListNode <T>();
         tmp.Value = item;
         if (First == null && Last == null)
         {
             tmp.Next = Last;
             tmp.Prev = First;
             First    = Last = tmp;
         }
         else
         {
             tmp.Next = First;
             First    = tmp;
         }
     }
 }