public void Print() { Queue queue = new Queue(); Console.WriteLine("Head"); NodeQ node = null; while ((node = queue.Poll()) != null) { Console.WriteLine($"{node.data}<-"); } Console.WriteLine("Tail"); }
public NodeQ Poll() { NodeQ p = head; if (p == null) { return(null); } head = head.prev; p.next = null; p.prev = null; size--; return(p); }
public void Offer(string element) { if (head == null) { head = new NodeQ(element); tail = head; } else { NodeQ newNode = new NodeQ(element); newNode.next = tail; tail.prev = newNode; tail = newNode; } size++; }