Source of 11.31.java


  1: public T removeFront()
  2: {
  3:    T front = getFront();  // Might throw EmptyQueueException
  4:    assert firstNode != null;
  5:    firstNode = firstNode.getNextNode();
  6: 
  7:    if (firstNode == null)
  8:       lastNode = null;
  9:    else
 10:       firstNode.setPreviousNode(null);
 11: 
 12:    return front;
 13: } // end removeFront
 14: 
 15: public T removeBack()
 16: {
 17:    T back = getBack();  // Might throw EmptyQueueException
 18:    assert lastNode != null;
 19:    lastNode = lastNode.getPreviousNode();
 20: 
 21:    if (lastNode == null)
 22:       firstNode = null;
 23:    else
 24:       lastNode.setNextNode(null);
 25:    } // end if
 26: 
 27:    return back;
 28: } // end removeBack
 29: // Version 4.0