public override void Insert(T value) { base.size++; SONode <T> newNode = new SONode <T>(value); lastNode.SetNext(newNode); lastNode = newNode; }
public bool MoveNext() { if (current != null) { current = current.Next; } return(current != null); }
private T[] CreateTailArray(SONode <T> firstElement, int size) { T[] array = new T[size]; for (int i = 0; i < size; i++) { array[i] = firstElement.Value; firstElement = firstElement.Next; } return(array); }
public override void Remove(T value) { SONode <T> current = base.preHead; while (current.Next != null) { if (EqualityComparer <T> .Default.Equals(current.Next.Value, value)) { current.SetNext(current.Next.Next); current.Next.SetNext(null); break; } } }
public override T[] GetTail(T origin) { SONode <T> iter = base.preHead.Next; int startIndex = 0; while (iter != null) { if (EqualityComparer <T> .Default.Equals(origin, iter.Value)) { int arraySize = size - startIndex - 1; T[] tail = CreateTailArray(iter.Next, arraySize); return(tail); } iter = iter.Next; startIndex++; } T[] empty = new T[0]; return(empty); }
public override bool Contains(T value) { SONode <T> prev = base.preHead; SONode <T> next = prev.Next; for (; next != null; next = next.Next) { if (EqualityComparer <T> .Default.Equals(next.Value, value)) { prev.SetNext(next.Next); next.SetNext(preHead.Next); preHead.SetNext(next); return(true); } } return(false); }
public void Reset() { current = preHead; }
public SOListIterator(SONode <T> head) { this.current = head; this.preHead = head; }
protected SOListBase(SONode <T> preHead) { this.preHead = preHead; this.size = 0; }
public mtfSOList() : base(new SONode <T>()) { lastNode = base.preHead; }