Exemple #1
0
        private void SetHeadAndTail(T data)
        {
            var item = new SLinkedListItem <T>(data);

            Head  = item;
            Tail  = item;
            Count = 1;
        }
Exemple #2
0
        public void AppendHead(T data)
        {
            var item = new SLinkedListItem <T>(data)
            {
                Next = Head
            };

            Head = item;
            Count++;
        }
Exemple #3
0
        public bool MoveNext()
        {
            if (_isFirstTimeMoveNext)
            {
                _isFirstTimeMoveNext = false;
            }
            else
            {
                _current = _current.Next;
            }

            return(this._current != null);
        }
Exemple #4
0
 public void Add(T data)
 {
     if (Tail != null)
     {
         var item = new SLinkedListItem <T>(data);
         Tail.Next = item;
         Tail      = item;
         Count++;
     }
     else
     {
         SetHeadAndTail(data);
     }
 }
Exemple #5
0
 public void InsertAfter(T target, T data)
 {
     if (Head != null)
     {
         var current = Head;
         while (current != null)
         {
             if (current.Data.Equals(target))
             {
                 var item = new SLinkedListItem <T>(data);
                 item.Next    = current.Next;
                 current.Next = item;
                 Count++;
                 return;
             }
             else
             {
                 current = current.Next;
             }
         }
     }
 }
Exemple #6
0
 public void Dispose()
 {
     _current             = null;
     _isFirstTimeMoveNext = true;
     _doublyLinkedList    = null;
 }
Exemple #7
0
 public void Reset()
 {
     _isFirstTimeMoveNext = true;
     _current             = _doublyLinkedList.Head;
 }
Exemple #8
0
 public LinkedListEnumerator(SLinkedList <T> sLinkedList)
 {
     this._doublyLinkedList = sLinkedList;
     this._current          = sLinkedList.Head;
     this._nullCurrent      = new SLinkedListItem <T>((T)Activator.CreateInstance(typeof(T)));
 }