public void RemoveLast()
 {
     if (last != null)
     {
         bool bSetCur = (current == last);
         if (last.Previous == null)
         {
             last    = null;
             first   = null;
             current = null;
         }
         else
         {
             last.Previous.Next = null;
             last = last.Previous;
             if (bSetCur)
             {
                 current = null;
             }
         }
     }
 }
 public void RemoveFirst()
 {
     if (first != null)
     {
         bool bSetCur = (current == first);
         if (first.Next == null)
         {
             last    = null;
             first   = null;
             current = null;
         }
         else
         {
             first.Next.Previous = null;
             first = first.Next;
             if (bSetCur)
             {
                 current = null;
             }
         }
     }
 }
 public void Remove(object v)
 {
     if (first != null)
     {
         LinkedListItem item = first;
         while (item != null)
         {
             if (v == item.Value)
             {
                 LinkedListItem prev = item.Previous;
                 if (prev == null)
                 {
                     //item is the first
                     RemoveFirst();
                 }
                 else
                 {
                     LinkedListItem next = item.Next;
                     if (next == null)
                     {
                         RemoveLast();
                     }
                     else
                     {
                         prev.Next     = next;
                         next.Previous = prev;
                     }
                 }
                 break;
             }
             else
             {
                 item = item.Next;
             }
         }
     }
 }
 public void Clear()
 {
     current = null;
     first   = null;
     last    = null;
 }