magi.toolkit.util.queue
Class FIFOQueue

java.lang.Object
  |
  +--magi.toolkit.util.queue.FIFOQueue
All Implemented Interfaces:
Queue

public class FIFOQueue
extends java.lang.Object
implements Queue

A "First In, First Out" implementation of the Queue interface.

Author:
Paul Atkinson, Magi Systems Pty Ltd
See Also:
Queue

Constructor Summary
FIFOQueue()
          Default constructor.
FIFOQueue(java.lang.Object[] objects)
          Create a FIFO Queue pre-populated with the elements provided.
 
Method Summary
 boolean isEmpty()
          Returns true if the queue currently contains no elements.
 java.lang.Object peek()
          Peek at the next Object available in the queue.
 java.lang.Object[] peekAll()
          Peek at all Objects available in the queue, in the correct queueing order.
 java.lang.Object pop()
          Pops an Object off the queue.
 java.lang.Object[] popAll()
          Pops all Objects off the queue, in the correct queueing order.
 void push(java.lang.Object object)
          Pushes an Object into the queue.
 void pushAll(java.lang.Object[] object)
          Pushes an array of Objects into the queue.
 void remove(java.lang.Object object)
          Removes an Object directly from this queue, regardless of its current position in the queue.
 int size()
          Returns the number of Objects currently in the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FIFOQueue

public FIFOQueue()
Default constructor.


FIFOQueue

public FIFOQueue(java.lang.Object[] objects)
Create a FIFO Queue pre-populated with the elements provided. The elements are queued up from left to right, where element 0 is the first to pop, element 1 will be next, and so on.

Parameters:
objects - an array of Objects to queue up.
Method Detail

push

public void push(java.lang.Object object)
Pushes an Object into the queue.

Specified by:
push in interface Queue
Parameters:
object - the Object to insert.

pushAll

public void pushAll(java.lang.Object[] object)
Pushes an array of Objects into the queue. The elements are queued from left to right, where element 0 is queued first, element 1 is queued next, and so on.

Specified by:
pushAll in interface Queue
Parameters:
object - the Object array to queue up.

pop

public java.lang.Object pop()
Pops an Object off the queue.

Specified by:
pop in interface Queue
Returns:
the Object removed from the queue.

popAll

public java.lang.Object[] popAll()
Pops all Objects off the queue, in the correct queueing order. This means that the next object due to be popped is element 0, and the next is element 1, and so on. Popping order is left to right.

Specified by:
popAll in interface Queue
Returns:
the Object array removed from the queue.

peek

public java.lang.Object peek()
Peek at the next Object available in the queue. This method does NOT remove the Object from the queue.

Specified by:
peek in interface Queue
Returns:
the Object that is next in the queue.

peekAll

public java.lang.Object[] peekAll()
Peek at all Objects available in the queue, in the correct queueing order. This means that the next object due to be popped is element 0, and the next is element 1, and so on. This method does NOT remove any Objects from the queue.

Specified by:
peekAll in interface Queue
Returns:
the Object array in the queue.

size

public int size()
Returns the number of Objects currently in the queue.

Specified by:
size in interface Queue
Returns:
the int size of the queue collection.

isEmpty

public boolean isEmpty()
Returns true if the queue currently contains no elements.

Specified by:
isEmpty in interface Queue
Returns:
true if empty, false if not.

remove

public void remove(java.lang.Object object)
Removes an Object directly from this queue, regardless of its current position in the queue.

Specified by:
remove in interface Queue
Parameters:
object - the Object to remove.