com.croftsoft.core.util.queue
Class VectorQueue

java.lang.Object
  extended by com.croftsoft.core.util.queue.VectorQueue
All Implemented Interfaces:
Queue

public final class VectorQueue
extends Object
implements Queue

An implementation of Queue that relies upon a Vector backbone.

Since:
1999-02-07
Version:
2003-05-22
Author:
David Wallace Croft

Constructor Summary
VectorQueue()
           
VectorQueue(Vector vector)
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VectorQueue

public VectorQueue(Vector vector)

VectorQueue

public VectorQueue()
Method Detail

append

public boolean append(Object o)
Description copied from interface: Queue
Appends the object to the queue and notifies any threads that are blocked in pull().

Specified by:
append in interface Queue
Returns:
Returns true if the object could be added to the queue.

poll

public Object poll()
Description copied from interface: Queue
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.

Specified by:
poll in interface Queue
Returns:
An object, if one was immediately available, otherwise null.

pull

public Object pull()
            throws InterruptedException
Description copied from interface: Queue
Remove the next object in this queue, blocking until one becomes available.

Specified by:
pull in interface Queue
Throws:
InterruptedException - If the wait is interrupted.

pull

public Object pull(long timeout)
            throws InterruptedException
Description copied from interface: Queue
Remove the next object in this queue, blocking until one becomes available or the given timeout period expires.

Specified by:
pull in interface Queue
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:
InterruptedException - If the timeout wait is interrupted.

replace

public Object replace(Object o)
Description copied from interface: Queue
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.

Specified by:
replace in interface Queue
Returns:
The old object, if available, otherwise null.

CroftSoft Javadoc

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