All Packages Class Hierarchy This Package Previous Next Index
Class magician.Node.HashQueue
java.lang.Object
|
+----java.util.Dictionary
|
+----java.util.Hashtable
|
+----magician.Node.HashQueue
- public class HashQueue
- extends Hashtable
A blocking queue of elements. Readers of the queue block when attempting to read when the
queue is empty. The readers are woken up when an element is inserted into the queue.
-
HashQueue()
- constructs an empty queue
-
HashQueue(int)
-
constructs a queue of the specified size
-
delete(Object)
- retrieves the element of the queue specified by given key.
-
fetch(Object)
- returns a reference to the element specified by given key but does not remove the element
from the queue.
-
insert(Object, Object)
-
inserts an object into the queue.
HashQueue
public HashQueue()
- constructs an empty queue
HashQueue
public HashQueue(int size)
- constructs a queue of the specified size
- Parameters:
- size - the initial size of the queue
insert
public synchronized Object insert(Object key,
Object element)
- inserts an object into the queue. If the queue was previously empty,
wakes up any sleeping readers
- Parameters:
- key - the key under which data object is to be stored
- element - the data object to be placed on the queue
delete
public synchronized Object delete(Object key)
- retrieves the element of the queue specified by given key. If the queue is empty,
this method blocks until one is available.
- Parameters:
- key - key for the requiree element
- Returns:
- s the first element of the queue
- Throws: InterruptedException
- if operation is interrupted
fetch
public synchronized Object fetch(Object key) throws InterruptedException
- returns a reference to the element specified by given key but does not remove the element
from the queue. If the queue is empty, it returns null.
- Parameters:
- key - key for the required element
- Returns:
- s the element or null if there is no element associated by that key
All Packages Class Hierarchy This Package Previous Next Index