jcontrol.util
Class Queue

java.lang.Object
  extended by jcontrol.util.Queue

public class Queue
extends Object

A queue is a FIFO (First-In-First-Out) buffer. When elements are pushed into the queue they are appended at the end. Popping elements always returns the element at the first index, i.e. the oldest element.


Constructor Summary
Queue(int initialSize)
          Creates a Queue instance.
 
Method Summary
 int getSize()
          Returns the size of the queue.
 Object pop()
          Removes the oldest element from the queue and returns it.
 void push(Object o)
          Pushes any object into the queue.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notifyAll, toString, wait
 

Constructor Detail

Queue

public Queue(int initialSize)
Creates a Queue instance.

Parameters:
initialSize - the initial size of the internal data array. If the length of the queue exceeds this initial size, the data array will be enlarged.
Method Detail

push

public void push(Object o)
Pushes any object into the queue.

Parameters:
o - an object to push into the queue.

pop

public Object pop()
Removes the oldest element from the queue and returns it.

Returns:
the oldest element or null if the queue is empty.

getSize

public int getSize()
Returns the size of the queue.

Returns:
the number of elements in the queue.