edu.umass.cs.mallet.base.util.search
Interface PriorityQueue

All Known Implementing Classes:
MinHeap

public interface PriorityQueue

Created by IntelliJ IDEA. User: pereira Date: Jun 18, 2005 Time: 7:46:46 PM Interface representing the basic methods for a priority queue.


Method Summary
 boolean contains(QueueElement e)
          Does the queue contain an element?
 void decreaseKey(QueueElement e, double priority)
          Lower the priority of queue element e to priorrity.
 QueueElement extractMin()
          Remove the top element of the queue.
 void insert(QueueElement e)
          Insert element e into the queue.
 QueueElement min()
          Return the top element of the queue.
 int size()
          The current size of the queue.
 

Method Detail

insert

public void insert(QueueElement e)
Insert element e into the queue.

Parameters:
e - the element to insert

size

public int size()
The current size of the queue.

Returns:
current size

min

public QueueElement min()
Return the top element of the queue.

Returns:
top element of the queue

extractMin

public QueueElement extractMin()
Remove the top element of the queue.

Returns:
the element removed

decreaseKey

public void decreaseKey(QueueElement e,
                        double priority)
Lower the priority of queue element e to priorrity. The element's position in the queue is adjusted as needed. IllegalArgumentExceptions are thrown if the element is not in the queue or if the new priority value is greater than the old value.

Parameters:
e - the element that has been changed
priority - the new priority

contains

public boolean contains(QueueElement e)
Does the queue contain an element?

Parameters:
e - the element
Returns:
whether the queue contains the element