org.ws4d.java.structures
Class Queue

java.lang.Object
  extended by org.ws4d.java.structures.Queue
Direct Known Subclasses:
WaitingQueue

public class Queue
extends java.lang.Object

Simple Queue. Thread safe!?! ;-)


Constructor Summary
Queue()
          Create a new fine queue.
 
Method Summary
 java.lang.Object checkFirst()
          Returns the first element of this queue WITHOUT removing it!
 void clear()
          Removes all entries from this queue.
 void enqueue(java.lang.Object o)
          Enqueues element into this queue.
 void enqueueAtBeginning(java.lang.Object o)
          Adds elements to this queue, but the element will be set on the beginning of the queue.
 java.lang.Object get()
          Returns the first element of this queue.
 boolean isEmpty()
          Tests that this queue has no components.
 Iterator iterator()
          Returns an iterator for this queue.
 int size()
          Returns the number of components in this queue.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Create a new fine queue.

Method Detail

isEmpty

public boolean isEmpty()
Tests that this queue has no components.

Returns:
true if and only if this queue has no components, that is, its size is zero; false otherwise.

enqueue

public void enqueue(java.lang.Object o)
Enqueues element into this queue.

Parameters:
o - element to enqueue.

enqueueAtBeginning

public void enqueueAtBeginning(java.lang.Object o)
Adds elements to this queue, but the element will be set on the beginning of the queue.

Parameters:
o - element to enqueue.

get

public java.lang.Object get()
Returns the first element of this queue. The first element is removed from queue, element at index 1 becomes first, etc.

Returns:
The first element.

checkFirst

public java.lang.Object checkFirst()
Returns the first element of this queue WITHOUT removing it!

Returns:
The first element.

clear

public void clear()
Removes all entries from this queue.


iterator

public Iterator iterator()
Returns an iterator for this queue.

This iterator allows to access every item inside this queue and supports the remove method.

Returns:
the iterator for this queue.

size

public int size()
Returns the number of components in this queue.

Returns:
the number of components in this queue.