com.croftsoft.core.util.queue
Interface Queue

All Known Implementing Classes:
ListQueue, VectorQueue

public interface Queue

An interface for queues.

Since:
1998-11-23
Version:
2003-06-18
Author:
David Wallace Croft

Method Summary
 boolean append(Object o)
          Appends the object to the queue and notifies any threads that are blocked in pull().
 Object poll()
          Poll this queue to see if an object is available, immediately removing one if so.
 Object pull()
          Remove the next object in this queue, blocking until one becomes available.
 Object pull(long timeout)
          Remove the next object in this queue, blocking until one becomes available or the given timeout period expires.
 Object replace(Object o)
          Replaces the first occurrence of any equal object in the queue.
 

Method Detail

append

boolean append(Object o)
Appends the object to the queue and notifies any threads that are blocked in pull().

Returns:
Returns true if the object could be added to the queue.

poll

Object poll()
Poll this queue to see if an object is available, immediately removing one if so. If the queue is empty, this method immediately returns null.

Returns:
An object, if one was immediately available, otherwise null.

pull

Object pull()
            throws InterruptedException
Remove the next object in this queue, blocking until one becomes available.

Throws:
InterruptedException - If the wait is interrupted.

pull

Object pull(long timeout)
            throws InterruptedException
Remove the next object in this queue, blocking until one becomes available or the given timeout period expires.

Parameters:
timeout - If positive, block for up to timeout milliseconds while waiting for an object to be added to this queue. If zero, block indefinitely.
Returns:
An object, if one was available within the specified timeout period, otherwise null.
Throws:
IllegalArgumentException - If the value of the timeout argument is negative.
InterruptedException - If the timeout wait is interrupted.

replace

Object replace(Object o)
               throws IndexOutOfBoundsException
Replaces the first occurrence of any equal object in the queue. The new object is placed in the same queue order as the old. If the new object is unique, it is simply appended.

Returns:
The old object, if available, otherwise null.
Throws:
IndexOutOfBoundsException - If appending would cause the queue to exceed the maximum size.

CroftSoft Javadoc

CroftSoft Core Javadoc (2008-09-28 20:58:02)