structure
Class QueueVector

java.lang.Object
  extended by structure.AbstractStructure
      extended by structure.AbstractLinear
          extended by structure.AbstractQueue
              extended by structure.QueueVector
All Implemented Interfaces:
Linear, Queue, Structure

public class QueueVector
extends AbstractQueue
implements Queue

An implementation of queues written using vectors.


Constructor Summary
QueueVector()
          Construct an empty queue
QueueVector(int size)
          Constructs an empty queue with an initial allocation of size.
 
Method Summary
 void add(Object value)
          Add a value to the tail of the queue
 void clear()
          Remove all the values from the queue.
 Object get()
          Fetch the value at the head of the queue.
 boolean isEmpty()
          Determine if the queue is empty.
 Iterator iterator()
          Returns an iterator for traversing the structure.
 Object remove()
          Remove a value from the head of the queue
 int size()
          Determine the number of elements within the queue.
 String toString()
          Construct a string representation of the queue.
 
Methods inherited from class structure.AbstractQueue
dequeue, enqueue, getFirst, peek
 
Methods inherited from class structure.AbstractLinear
empty, remove
 
Methods inherited from class structure.AbstractStructure
contains, elements, hashCode, values
 
Methods inherited from class java.lang.Object
equals, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface structure.Queue
dequeue, empty, enqueue, getFirst, peek
 
Methods inherited from interface structure.Structure
contains, elements, remove, values
 

Constructor Detail

QueueVector

public QueueVector()
Construct an empty queue


QueueVector

public QueueVector(int size)
Constructs an empty queue with an initial allocation of size.

Parameters:
size - Approximate largest queue size needed.
Method Detail

add

public void add(Object value)
Add a value to the tail of the queue

Specified by:
add in interface Linear
Specified by:
add in interface Queue
Specified by:
add in interface Structure
Parameters:
value - The value added.
See Also:
Queue.enqueue(java.lang.Object)

remove

public Object remove()
Remove a value from the head of the queue

Specified by:
remove in interface Linear
Specified by:
remove in interface Queue
Returns:
The value actually removed.
See Also:
AbstractQueue.dequeue()

get

public Object get()
Fetch the value at the head of the queue.

Specified by:
get in interface Linear
Specified by:
get in interface Queue
Returns:
Reference to the first value of the queue.

size

public int size()
Determine the number of elements within the queue.

Specified by:
size in interface Linear
Specified by:
size in interface Queue
Specified by:
size in interface Structure
Returns:
The number of elements within the queue.

clear

public void clear()
Remove all the values from the queue.

Specified by:
clear in interface Structure

isEmpty

public boolean isEmpty()
Determine if the queue is empty.

Specified by:
isEmpty in interface Structure
Overrides:
isEmpty in class AbstractStructure
Returns:
True iff the queue is empty.

iterator

public Iterator iterator()
Description copied from interface: Structure
Returns an iterator for traversing the structure.

Specified by:
iterator in interface Structure
Returns:
an iterator for traversing the structure
See Also:
AbstractIterator, Iterator, Enumeration, Structure.elements()

toString

public String toString()
Construct a string representation of the queue.

Overrides:
toString in class Object
Returns:
String representing the queue.