org.mbari.siam.utils
Class Queue

java.lang.Object
  extended by org.mbari.siam.utils.Queue

public class Queue
extends java.lang.Object

Queue class in which a queue of objects can be removed in the order that they are added. This class actually implements a double-ended queue, so elements can be added or removed from either end. Based on the Queue class by Yasser EL-Manzalawy


Nested Class Summary
 class Queue.EmptyQueue
          Thrown when item is requested
 
Constructor Summary
Queue()
          Creats an empty queue
 
Method Summary
 void clear()
          Removes all elements at the queue.
 boolean empty()
           
 java.lang.Object front()
          Inspects the element at the top of the queue without removing it.
 java.lang.Object popBack()
          Removes the element at the back of the queue.
 java.lang.Object popFront()
          Removes the element at the front of the queue.
 java.lang.Object pushBack(java.lang.Object element)
          Put a new element at the back of the queue.
 java.lang.Object pushFront(java.lang.Object element)
          Put a new element at the front of the queue.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Creats an empty queue

Method Detail

pushBack

public java.lang.Object pushBack(java.lang.Object element)
Put a new element at the back of the queue.

Parameters:
element - element to be inserted.

pushFront

public java.lang.Object pushFront(java.lang.Object element)
Put a new element at the front of the queue.

Parameters:
element - element to be inserted.

popFront

public java.lang.Object popFront()
                          throws Queue.EmptyQueue
Removes the element at the front of the queue.

Returns:
the removed element.
Throws:
Queue.EmptyQueue - if the queue is empty.

popBack

public java.lang.Object popBack()
                         throws Queue.EmptyQueue
Removes the element at the back of the queue.

Returns:
the removed element.
Throws:
Queue.EmptyQueue - if the queue is empty.

front

public java.lang.Object front()
                       throws Queue.EmptyQueue
Inspects the element at the top of the queue without removing it.

Returns:
the element at the top of the queue.
Throws:
EmptyQueueException - if the queue is empty.
Queue.EmptyQueue

size

public int size()
Returns:
the number of elements at the queue.

empty

public boolean empty()
Returns:
true of the queue is empty.

clear

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



Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.