public abstract class AQueue<E> extends java.lang.Object implements IQueue<E>
Some methods in IQueue are pairs that do the same job, but report failure differently. Implement the fail-by-throwing methods here, in this abstract class, by calling the paired method and checking the return value, then throwing as appropriate. Why is defining these methods here desirable? What are some alternatives?
created by cspfrederick
and garethhalladay
Fall17
inspired by Chris Wilcox
Constructor and Description |
---|
AQueue() |
Modifier and Type | Method and Description |
---|---|
void |
add(E item)
Inserts the specified element into this queue,
returning true upon success.
|
E |
element()
Retrieves, but does not remove, the head of this queue.
|
boolean |
isEmpty()
Returns true if this queue contains no elements.
|
E |
remove()
Retrieves and removes the head of this queue.
|
public void add(E item)
IQueue
This method throws an IllegalStateException if no space is available to hold the new item.
public E remove()
IQueue
public E element()
IQueue