|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.pivot.collections.concurrent.SynchronizedQueue<T>
public class SynchronizedQueue<T>
Synchronized implementation of the Queue
interface.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.pivot.collections.Queue |
---|
Queue.QueueListenerList<T> |
Constructor Summary | |
---|---|
SynchronizedQueue(Queue<T> queue)
|
Method Summary | |
---|---|
void |
clear()
Removes all elements from the collection. |
T |
dequeue()
Removes the item from the head of the queue and returns it. |
void |
enqueue(T item)
Enqueues an item. |
Comparator<T> |
getComparator()
Returns the collection's sort order. |
int |
getLength()
Returns the length of the queue. |
ListenerList<QueueListener<T>> |
getQueueListeners()
Returns the queue listener list. |
boolean |
isEmpty()
Tests the emptiness of the queue. |
Iterator<T> |
iterator()
NOTE Callers must manually synchronize on the SynchronizedQueue instance to ensure thread safety during iteration. |
T |
peek()
Returns the item at the head of the queue without removing it from the queue. |
void |
setComparator(Comparator<T> comparator)
Sets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SynchronizedQueue(Queue<T> queue)
Method Detail |
---|
public void enqueue(T item)
Queue
enqueue
in interface Queue<T>
item
- The item to add to the queue.public T dequeue()
Queue
remove(getLength() - 1, 1);
dequeue
in interface Queue<T>
public T peek()
Queue
peek
in interface Queue<T>
public void clear()
Collection
clear
in interface Collection<T>
public boolean isEmpty()
Queue
isEmpty
in interface Collection<T>
isEmpty
in interface Queue<T>
public int getLength()
Queue
getLength
in interface Queue<T>
public Comparator<T> getComparator()
Collection
getComparator
in interface Collection<T>
Collection.setComparator(Comparator)
public void setComparator(Comparator<T> comparator)
Collection
Calling this method more than once with the same comparator will re-sort the collection.
setComparator
in interface Collection<T>
comparator
- The comparator used to order elements in the collection, or null if the
collection is unsorted.public Iterator<T> iterator()
iterator
in interface Iterable<T>
public ListenerList<QueueListener<T>> getQueueListeners()
Queue
getQueueListeners
in interface Queue<T>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |