PircBot Java IRC Bot

org.jibble.pircbot
Class Queue

java.lang.Object
  extended byorg.jibble.pircbot.Queue

public class Queue
extends Object

Queue is a definition of a data structure that may act as a queue - that is, data can be added to one end of the queue and data can be requested from the head end of the queue. This class is thread safe for multiple producers and a single consumer. The next() method will block until there is data in the queue. This has now been modified so that it is compatible with the earlier JDK1.1 in order to be suitable for running on mobile appliances. This means replacing the LinkedList with a Vector, which is hardly ideal, but this Queue is typically only polled every second before dispatching messages.

Version:
1.5.0 (Build time: Mon Dec 14 20:07:17 2009)
Author:
Paul James Mutton, http://www.jibble.org/

Constructor Summary
Queue()
          Constructs a Queue object of unlimited size.
 
Method Summary
 void add(Object o)
          Adds an Object to the end of the Queue.
 void addFront(Object o)
          Adds an Object to the front of the Queue.
 void clear()
          Clears the contents of the Queue.
 boolean hasNext()
          Returns true if the Queue is not empty.
 Object next()
          Returns the Object at the front of the Queue.
 int size()
          Returns the size of the Queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Constructs a Queue object of unlimited size.

Method Detail

add

public void add(Object o)
Adds an Object to the end of the Queue.

Parameters:
o - The Object to be added to the Queue.

addFront

public void addFront(Object o)
Adds an Object to the front of the Queue.

Parameters:
o - The Object to be added to the Queue.

next

public Object next()
Returns the Object at the front of the Queue. This Object is then removed from the Queue. If the Queue is empty, then this method shall block until there is an Object in the Queue to return.

Returns:
The next item from the front of the queue.

hasNext

public boolean hasNext()
Returns true if the Queue is not empty. If another Thread empties the Queue before next() is called, then the call to next() shall block until the Queue has been populated again.

Returns:
True only if the Queue not empty.

clear

public void clear()
Clears the contents of the Queue.


size

public int size()
Returns the size of the Queue.

Returns:
The current size of the queue.

PircBot Java IRC Bot