public IEnumerable <T> BackEnumerator() { DoubleNode <T> current = this.tail; while (current != null) { yield return(current.Data); current = current.Previous; } }
public IEnumerator <T> GetEnumerator() { DoubleNode <T> current = this.head; while (current != null) { yield return(current.Data); current = current.Next; } }
public bool Contains(T data) { DoubleNode <T> current = this.head; while (current != null) { if (current.Data.Equals(data)) { return(true); } current = current.Next; } return(false); }
public void Add(T data) { DoubleNode <T> node = new DoubleNode <T>(data); if (this.head == null) { this.head = node; } else { this.tail.Next = node; node.Previous = this.tail; } this.tail = node; this.count++; }
public void AddFirst(T data) { DoubleNode <T> node = new DoubleNode <T>(data); DoubleNode <T> temp = this.head; node.Next = temp; this.head = node; if (this.count == 0) { this.tail = this.head; } else { temp.Previous = node; } this.count++; }
public void Clear() { this.head = null; this.tail = null; this.count = 0; }