org.apache.commons.collections

Class SynchronizedPriorityQueue

public final class SynchronizedPriorityQueue extends Object implements PriorityQueue

Deprecated: PriorityQueue is replaced by the Buffer interface, see buffer subpackage. Due to be removed in v4.0.

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

Version: $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $

Author: Ram Chidambaram

Field Summary
protected PriorityQueuem_priorityQueue
The underlying priority queue.
Constructor Summary
SynchronizedPriorityQueue(PriorityQueue priorityQueue)
Constructs a new synchronized priority queue.
Method Summary
voidclear()
Clear all elements from queue.
voidinsert(Object element)
Insert an element into queue.
booleanisEmpty()
Test if queue is empty.
Objectpeek()
Return element on top of heap but don't remove it.
Objectpop()
Return element on top of heap and remove it.
StringtoString()
Returns a string representation of the underlying queue.

Field Detail

m_priorityQueue

protected final PriorityQueue m_priorityQueue
The underlying priority queue.

Constructor Detail

SynchronizedPriorityQueue

public SynchronizedPriorityQueue(PriorityQueue priorityQueue)
Constructs a new synchronized priority queue.

Parameters: priorityQueue the priority queue to synchronize

Method Detail

clear

public void clear()
Clear all elements from queue.

insert

public void insert(Object element)
Insert an element into queue.

Parameters: element the element to be inserted

isEmpty

public boolean isEmpty()
Test if queue is empty.

Returns: true if queue is empty else false.

peek

public Object peek()
Return element on top of heap but don't remove it.

Returns: the element at top of heap

Throws: NoSuchElementException if isEmpty() == true

pop

public Object pop()
Return element on top of heap and remove it.

Returns: the element at top of heap

Throws: NoSuchElementException if isEmpty() == true

toString

public String toString()
Returns a string representation of the underlying queue.

Returns: a string representation of the underlying queue

Copyright © 2001-2008 Apache Software Foundation. All Rights Reserved.