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(); } }
public int CompareTo(SLinkedListNode <T> other) { if (other == null) { return(-1); } return(this.Data.CompareTo(other.Data)); }
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++; }
public void Dispose() { _current = null; _doublyLinkedList = null; }
public void Reset() { _current = _doublyLinkedList.Head; }
public bool MoveNext() { _current = _current.Next; return(_current != null); }
public SLinkedListEnumerator(SLinkedList <T> list) { _doublyLinkedList = list; _current = list.Head; }