Exemplo n.º 1
0
 //
 // Summary:
 //     Advances the enumerator to the next element of the System.Collections.Generic.LinkedList<T>.
 //
 // Returns:
 //     true if the enumerator was successfully advanced to the next element; false
 //     if the enumerator has passed the end of the collection.
 //
 // Exceptions:
 //   System.InvalidOperationException:
 //     The collection was modified after the enumerator was created.
 public bool MoveNext()
 {
     if (_start)
     {
         // if (current == null) {      // circular
         _start   = false;
         _current = _list._head;
     }
     else if (_current == null)
     {
         return(false);
     }
     else
     {
         _current = _current.Next;
     }
     return(HasCurrent());
 }
Exemplo n.º 2
0
 public void Remove(DoublyLinkedListNode <T> node)
 {
     if (node == _head)
     {
         // Remove head
         node.Pre = null;
         _head    = node.Next;
     }
     else if (node == _tail)
     {
         // Remove tail
         _tail     = node.Pre;
         _tail.Nex = null;
     }
     else
     {
         // Remove middle
         var pre = node.Pre;
         var nex = node.Nex;
         pre.Nex = nex;
         nex.Pre = pre;
     }
     Count--;
 }
Exemplo n.º 3
0
 private void connect(DoublyLinkedListNode <T> n1, DoublyLinkedListNode <T> n2)
 {
     n1.Nex = n2;
     n2.Pre = n1;
 }
Exemplo n.º 4
0
 public void Reset()
 {
     _start   = true;
     _current = null;
 }
Exemplo n.º 5
0
 internal Enumerator(SortedDoublyLinkedList <T> list)
 {
     _list    = list;
     _current = null;
     _start   = true;
 }