public class ArrayQueue<E> extends java.lang.Object implements BoundedQueue<E>
Constructor and Description |
---|
ArrayQueue(int maxSize)
Creates an ArrayQueue whose size and capacity are both equal
to the input maxSize, and whose entries are all null,
if this is a positive int - throwing an
IllegalArgumentException if the input maxSize is negative,
instead.
|
Modifier and Type | Method and Description |
---|---|
int |
capacity()
Reports the capacity of this bounded queue.
|
void |
insert(E x)
Inserts a new entry onto the queue.
|
boolean |
isEmpty()
Reports whether the queue is currently empty without changing it.
|
E |
peek()
Reports the element at the front of the queue without changing it.
|
E |
remove()
Removes an element from the front of the queue and reports it.
|
public ArrayQueue(int maxSize)
maxSize
- the capacity of the BoundedQueue to be createdpublic void insert(E x) throws QueueFullException
BoundedQueue
insert
in interface BoundedQueue<E>
x
- the object to be inserted onto the queueQueueFullException
- if the queue is already full
public E peek()
BoundedQueue
peek
in interface BoundedQueue<E>
public E remove()
BoundedQueue
remove
in interface BoundedQueue<E>
public boolean isEmpty()
BoundedQueue
isEmpty
in interface BoundedQueue<E>
public int capacity()
BoundedQueue
capacity
in interface BoundedQueue<E>