|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcc.mallet.util.search.MinHeap
public class MinHeap
Created by IntelliJ IDEA. User: pereira Date: Jun 18, 2005 Time: 9:11:24 PM
Binary heap implementation ofPriorityQueue.
Based on algorithm in Corman, Leiserson, Rivest, and Stein (Section 6.5).
| Constructor Summary | |
|---|---|
MinHeap()
Create a binary heap with minimum initial capacity. |
|
MinHeap(int capacity)
Create a binary heap with initial capacity capacity. |
|
| Method Summary | |
|---|---|
void |
changePriority(QueueElement e,
double priority)
Change the priority of queue element e to priority. |
boolean |
contains(QueueElement e)
Does the queue contain an element? |
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. |
QueueElement[] |
toArray()
Returns any array containing all of the elements in the queue. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MinHeap(int capacity)
capacity.
The heap's capacity grows as needed to accomodate insertions.
capacity - initial capacitypublic MinHeap()
| Method Detail |
|---|
public int size()
PriorityQueue
size in interface PriorityQueuepublic QueueElement min()
PriorityQueue
min in interface PriorityQueuepublic QueueElement extractMin()
PriorityQueue
extractMin in interface PriorityQueue
public void changePriority(QueueElement e,
double priority)
PriorityQueuee to priority.
The element's position in the queue is adjusted as needed.
changePriority in interface PriorityQueuee - the element that has been changedpriority - the new prioritypublic void insert(QueueElement e)
PriorityQueuee into the queue.
insert in interface PriorityQueuee - the element to insertpublic boolean contains(QueueElement e)
PriorityQueue
contains in interface PriorityQueuee - the element
public QueueElement[] toArray()
PriorityQueue
toArray in interface PriorityQueue
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||