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.


Variable Index

 o CAPACITY
Default maximum capacity of the queue.

Constructor Index

 o ArrayQueue()
This constructor initializes the queue with the default capacity specified by the CAPACITY constant.
 o ArrayQueue(int)
This constructor initializes the queue with the capacity specified by the user.

Method Index

 o dequeue()
Removes the element which is the first element in the queue and return a reference to it.
 o enqueue(Object)
Inserts a new object at the rear of the queue.
 o front()
Return the element which is the first in the queue
 o isEmpty()
This function returns true if and only if the queue is empty
 o size()
Return the size of the queue, that is the number of elements it has.

Variables

 o CAPACITY
 public static final int CAPACITY
Default maximum capacity of the queue.

Constructors

 o ArrayQueue
 public ArrayQueue()
This constructor initializes the queue with the default capacity specified by the CAPACITY constant.

 o ArrayQueue
 public ArrayQueue(int cap)
This constructor initializes the queue with the capacity specified by the user.

Parameters:
cap - Capacity of the queue

Methods

 o 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
 o 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
 o front
 public Object front() throws QueueEmptyException
Return the element which is the first in the queue

Returns:
The first queue element
 o 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
 o 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