org.apache.commons.collections
Interface PriorityQueue

All Known Implementing Classes:
SynchronizedPriorityQueue, BinaryHeap

public interface PriorityQueue

Interface for priority queues. This interface does not dictate whether it is min or max heap.

Author:
Peter Donald

Method Summary
 void clear()
          Clear all elements from queue.
 void insert(Comparable element)
          Insert an element into queue.
 boolean isEmpty()
          Test if queue is empty.
 Comparable peek()
          Return element on top of heap but don't remove it.
 Comparable pop()
          Return element on top of heap and remove it.
 

Method Detail

clear

public void clear()
Clear all elements from queue.

insert

public void insert(Comparable 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 Comparable peek()
                throws NoSuchElementException
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 Comparable pop()
               throws NoSuchElementException
Return element on top of heap and remove it.
Returns:
the element at top of heap
Throws:
NoSuchElementException - if isEmpty() == true


Copyright © 2001 Apache Software Foundation. Documenation generated July 14 2001.