Пример #1
0
 /// <summary>
 /// Remove Tail node from the List and make previous node as Tail
 /// </summary>
 public void RemoveLast()
 {
     if (Count > 0)
     {
         if (Count == 1)
         {
             Clear();
         }
         else
         {
             DoublyLinkedListNode <T> previousOfTail = Tail.Previous;
             Tail.Previous       = null;
             previousOfTail.Next = null;
             Tail = previousOfTail;
             Count--;
         }
     }
 }
Пример #2
0
 //ICollection Contains
 /// <summary>
 /// Implementation of Icollection Contains method
 /// Return true of list contains the item specified in "item" parameter
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Contains(T item)
 {
     if (Count > 0)
     {
         if (Head.Value.Equals(item) || Tail.Value.Equals(item))
         {
             return(true);
         }
         else
         {
             DoublyLinkedListNode <T> current = Head.Next;
             while (current != Tail)
             {
                 if (current.Value.Equals(item))
                 {
                     return(true);
                 }
                 current = current.Next;
             }
         }
     }
     return(false);
 }