⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
org.apache.commons.collections

Class SynchronizedPriorityQueue

java.lang.Object
|
+--org.apache.commons.collections.SynchronizedPriorityQueue

All Implemented Interfaces:
PriorityQueue


public final class SynchronizedPriorityQueue
extends java.lang.Object
implements PriorityQueue

A thread safe version of the PriorityQueue. Provides synchronized wrapper methods for all the methods defined in the PriorityQueue interface.
Since:
Commons Collections 1.0
Author:
Ram Chidambaram

Field Summary

PriorityQueue

m_priorityQueue

The underlying priority queue.

Constructor Summary

SynchronizedPriorityQueue(final PriorityQueue priorityQueue)

Constructs a new synchronized priority queue.

Method Summary

synchronized void

clear()

Clear all elements from queue.

synchronized void

insert(final Object element)

Insert an element into queue.

synchronized boolean

isEmpty()

Test if queue is empty.

synchronized Object

peek()

Return element on top of heap but don't remove it.

synchronized Object

pop()

Return element on top of heap and remove it.

synchronized String

toString()

Returns a string representation of the underlying queue.

Field Details

m_priorityQueue

protected final PriorityQueue m_priorityQueue

The underlying priority queue.

Constructor Details

SynchronizedPriorityQueue

public SynchronizedPriorityQueue(final PriorityQueue priorityQueue)

Constructs a new synchronized priority queue.

Parameters:
priorityQueue - the priority queue to synchronize

Method Details

clear

public synchronized void clear()

Clear all elements from queue.


insert

public synchronized void insert(final Object element)

Insert an element into queue.

Parameters:
element - the element to be inserted

isEmpty

public synchronized boolean isEmpty()

Test if queue is empty.

Returns:
true if queue is empty else false.

peek

public synchronized Object peek()

Return element on top of heap but don't remove it.

Returns:
the element at top of heap
Throws:
- if isEmpty() == true

pop

public synchronized Object pop()

Return element on top of heap and remove it.

Returns:
the element at top of heap
Throws:
- if isEmpty() == true

toString

public synchronized String toString()

Returns a string representation of the underlying queue.

Returns:
a string representation of the underlying queue