goldman.collection.positional
Class Queue<E>

java.lang.Object
  extended by goldman.collection.positional.Queue<E>

public class Queue<E>
extends Object

A queue is a more specialized abstraction than a buffer that maintains a first-in, first-out (FIFO) line. Elements can only be inserted at the back of the line and removed from the front of the line.


Constructor Summary
Queue()
           
Queue(int capacity)
           
Queue(int capacity, boolean bounded)
           
Queue(int capacity, boolean bounded, boolean tracked)
           
 
Method Summary
 void clear()
          Removes all elements from the queue.
 boolean contains(E value)
          Returns true if and only if the given value is contained within the queue.
 E dequeue()
          Removes the element from the front of the queue.
 void enqueue(E element)
          Inserts element at the end of the queue
 int getSize()
          Returns the number of elements in the queue.
 boolean isEmpty()
          Returns true if and only if there are no elements in the queue.
 Locator<E> iterator()
          Returns an iterator initialized at FORE.
 E peek()
          Returns the first object in the queue.
 String toString()
          Returns a string representation of the elements in the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Queue

public Queue()

Queue

public Queue(int capacity)

Queue

public Queue(int capacity,
             boolean bounded)

Queue

public Queue(int capacity,
             boolean bounded,
             boolean tracked)
Method Detail

clear

public void clear()
Removes all elements from the queue.


contains

public boolean contains(E value)
Returns true if and only if the given value is contained within the queue.


getSize

public int getSize()
Returns the number of elements in the queue.


isEmpty

public boolean isEmpty()
Returns true if and only if there are no elements in the queue.


toString

public String toString()
Returns a string representation of the elements in the queue.

Overrides:
toString in class Object

iterator

public Locator<E> iterator()
Returns an iterator initialized at FORE.


peek

public E peek()
Returns the first object in the queue. The queue is not changed.


enqueue

public void enqueue(E element)
Inserts element at the end of the queue

Parameters:
element - the new element to insert
Throws:
AtCapacityException - a bounded queue is full

dequeue

public E dequeue()
Removes the element from the front of the queue.

Returns:
the object that was removed
Throws:
NoSuchElementException - the queue is empty