public void EnqueueFront(int val) { DQNode dNode = new DQNode(val); dNode.next = front; if (count > 0) { front.prev = dNode; } front = dNode; count++; if (count == 1) { rear = front; } }
public void EnqueueRear(int val) { DQNode dNode = new DQNode(val); dNode.prev = rear; if (count > 0) { rear.next = dNode; } rear = dNode; count++; if (count == 1) { front = dNode; } }
public int DequeueFront() { //Queue is empty if (count <= 0) { } int val = front.value; front = front.next; count--; if (count > 0) { front.prev = null; } else { rear = null; } return(val); }
public int DequeueRear() { if (count <= 0) { return(-1); } int val = rear.value; rear = rear.prev; count--; if (count > 0) { rear.next = null; } else { rear = null; } return(val); }