|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectinfovis.utils.Heap
public class Heap
An array-based binary heap implementation of a priority queue,
which also provides
an efficient update()
operation.
(A previous version of this class had implemented the commons-collections
PriorityQueue interface, which has since been deprecated.)
It contains extra infrastructure (a hash table) to keep track of the
position of each element in the array; thus, if the key value of an element
changes, it may be "resubmitted" to the heap via update
so that the heap can reposition it efficiently, as necessary.
Constructor Summary | |
---|---|
Heap()
Creates a MapBinaryHeap whose heap ordering
will be based on the natural ordering of the elements,
which must be Comparable . |
|
Heap(Comparator c)
Creates a MapBinaryHeap whose heap ordering
is based on the ordering of the elements specified by c . |
Method Summary | |
---|---|
void |
clear()
|
void |
insert(Object o)
|
boolean |
isEmpty()
|
Object |
peek()
|
Object |
pop()
|
int |
size()
|
void |
update(Object o)
Informs the heap that this object's internal key value has been updated, and that its place in the heap may need to be shifted (up or down). |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Heap(Comparator c)
MapBinaryHeap
whose heap ordering
is based on the ordering of the elements specified by c
.
public Heap()
MapBinaryHeap
whose heap ordering
will be based on the natural ordering of the elements,
which must be Comparable
.
Method Detail |
---|
public void clear()
public void insert(Object o)
public boolean isEmpty()
public Object peek() throws NoSuchElementException
NoSuchElementException
public Object pop() throws NoSuchElementException
NoSuchElementException
public int size()
public void update(Object o)
o
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |