All Packages Class Hierarchy This Package Previous Next Index
Class jdsl.simple.ref.ArrayQueue
java.lang.Object
|
+----jdsl.simple.ref.ArrayQueue
- public class ArrayQueue
- extends Object
- implements Queue
Implementation of the Queue interface using an array. The queue can store
at most a given number of elements; if the user tries to insert more than that,
number, an exception is thrown.
- Version:
- Thu Aug 21 19:31:31 1997
- Author:
- Natasha Gelfand
-
CAPACITY
-
Default maximum capacity of the queue.
-
ArrayQueue()
-
This constructor initializes the queue with the default capacity
specified by the CAPACITY constant.
-
ArrayQueue(int)
-
This constructor initializes the queue with the capacity specified by
the user.
-
dequeue()
-
Removes the element which is the first element in the queue and
return a reference to it.
-
enqueue(Object)
-
Inserts a new object at the rear of the queue.
-
front()
-
Return the element which is the first in the queue
-
isEmpty()
-
This function returns true if and only if the queue is empty
-
size()
-
Return the size of the queue, that is the number of elements it has.
CAPACITY
public static final int CAPACITY
- Default maximum capacity of the queue.
ArrayQueue
public ArrayQueue()
- This constructor initializes the queue with the default capacity
specified by the CAPACITY constant.
ArrayQueue
public ArrayQueue(int cap)
- This constructor initializes the queue with the capacity specified by
the user.
- Parameters:
- cap - Capacity of the queue
size
public int size()
- Return the size of the queue, that is the number of elements it has.
- Returns:
- Number of elements in the queue
isEmpty
public boolean isEmpty()
- This function returns true if and only if the queue is empty
- Returns:
- true if the queue is empty, false otherwise
front
public Object front() throws QueueEmptyException
- Return the element which is the first in the queue
- Returns:
- The first queue element
dequeue
public Object dequeue() throws QueueEmptyException
- Removes the element which is the first element in the queue and
return a reference to it.
- Returns:
- First element in the queue
enqueue
public void enqueue(Object obj)
- Inserts a new object at the rear of the queue.
- Parameters:
- obj - Object to insert
All Packages Class Hierarchy This Package Previous Next Index