public void Add(int data) { var node = new DoubleNode <int>(data); if (Head == null) { Head = node; } else { Tail.Next = node; node.Previous = Tail; } Tail = node; Count++; }
public void AddFirst(int data) { var node = new DoubleNode <int>(data); var temp = Head; node.Next = temp; Head = node; if (Count == 0) { Tail = Head; } else { temp.Previous = node; } Count++; }
public bool Remove(int data) { var current = Head; while (current != null) { if (current.Data.Equals(data)) { break; } current = current.Next; } if (current != null) { if (current.Next != null) { current.Next.Previous = current.Previous; } else { Tail = current.Previous; } if (current.Previous != null) { current.Previous.Next = current.Next; } else { Head = current.Next; } Count--; return(true); } return(false); }
public void Clear() { Head = null; Tail = null; Count = 0; }