예제 #1
0
        public void InsertAt(T dataItem, int index)
        {
            if (index == 0)
            {
                Prepend(dataItem);
            }
            else if (index == Count)
            {
                Append(dataItem);
            }
            else if (index > 0 && index < Count)
            {
                var currentNode = _firstNode;
                var newNode     = new SLinkedListNode <T>(dataItem);

                for (int i = 1; i != index; ++i)
                {
                    currentNode = currentNode.Next;
                }

                newNode.Next     = currentNode.Next;
                currentNode.Next = newNode;

                _count++;
            }
            else
            {
                throw new IndexOutOfRangeException();
            }
        }
예제 #2
0
        public int CompareTo(SLinkedListNode <T> other)
        {
            if (other == null)
            {
                return(-1);
            }

            return(this.Data.CompareTo(other.Data));
        }
예제 #3
0
        public void Append(T dataItem)
        {
            var newNode = new SLinkedListNode <T>(dataItem);

            if (_lastNode == null)
            {
                _firstNode = newNode;
                _lastNode  = newNode;
            }
            else
            {
                _lastNode.Next = newNode;
                _lastNode      = newNode;
            }

            _count++;
        }
예제 #4
0
 public void Dispose()
 {
     _current          = null;
     _doublyLinkedList = null;
 }
예제 #5
0
 public void Reset()
 {
     _current = _doublyLinkedList.Head;
 }
예제 #6
0
            public bool MoveNext()
            {
                _current = _current.Next;

                return(_current != null);
            }
예제 #7
0
 public SLinkedListEnumerator(SLinkedList <T> list)
 {
     _doublyLinkedList = list;
     _current          = list.Head;
 }