public void Clear() { Head = null; //while (Head != null) //{ // Head = Head.Next; //} cnt = 0; }
public void Print() { DequeNode <T> tempNode = Head; while (tempNode != null) { Console.WriteLine(tempNode.data); tempNode = tempNode.Next; } }
public DequeNode <T> DequeueLeft() { if (Head == null) { return(null); } DequeNode <T> DeqNode = Head; Head = Head.Next; cnt--; return(DeqNode); }
public DequeNode <T> DequeueRight() { if (Head == null) { return(null); } DequeNode <T> DeqNode = Tail; Tail = Tail.Pre; Tail.Next = null; cnt--; return(DeqNode); }
public bool Contains(T Data) { bool result = false; DequeNode <T> tempNode = Head; while (tempNode != null) { if (Compare(Data, tempNode.data)) { result = true; break; } else { tempNode = tempNode.Next; } } return(result); }
public void EnqueueLeft(T a_data) { if (Head == null) { this.Head = new DequeNode <T>(); this.Head.data = a_data; this.Head.Next = null; Tail = Head; } else { DequeNode <T> newNode = new DequeNode <T>(); newNode.data = a_data; newNode.Next = Head; Head = newNode; } cnt++; }
public void EnqueueRight(T a_data) { if (Head == null) { this.Head = new DequeNode <T>(); this.Head.data = a_data; this.Head.Next = null; Tail = Head; } else { DequeNode <T> newNode = new DequeNode <T>(); newNode.data = a_data; DequeNode <T> TempNode = Tail; Tail.Next = newNode; Tail = newNode; newNode.Pre = TempNode; } cnt++; }