public override T Remove(T value) { Assertion.Pre(value != null); if (this.tail == null) { return(default(T)); } if (value.Equals(this.tail.GetValue())) { return(RemoveFromTail()); } SinglyLinkedListElement <T> finger = this.tail.GetNext(); SinglyLinkedListElement <T> previous = null; while (finger != tail && !value.Equals(finger.GetValue())) { previous = finger; finger = finger.GetNext(); } if (finger == tail) { return(default(T)); } if (previous == null) { return(RemoveFromHead()); } else { previous.SetNext(finger.GetNext()); } this.count--; return(finger.GetValue()); }
public override bool Contains(T value) { Assertion.Pre(value != null); SinglyLinkedListElement <T> finger = this.tail; if (finger == null) { return(false); } do { if (value.Equals(finger.GetValue())) { return(true); } finger = finger.GetNext(); } while (finger != this.tail); return(false); }
public void SetValue(T value) { Assertion.Pre(IsValid()); this.cursor.SetValue(value); }
public T GetValue() { Assertion.Pre(IsValid()); return(this.cursor.GetValue()); }
public override T Next() { Assertion.Pre(HasMore()); return(this.vector.GetElementAt(this.current++)); }
public override T PeekTail() { Assertion.Pre(this.tail != null); return(this.tail.GetValue()); }