|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.stanford.nlp.util.ArrayHeap
ArrayHeap: Heap implementation. Values are all implicit in the comparator passed in on construction. Decrease key is supported, though only lg(n). Unlike the previous implementation of this class, this heap interprets the addition of an existing element as a "change key" which gets ignored unless it actually turns out to be a decrease key. Note that in this implementation, changing the key of an object should trigger a change in the comparator's ordering for that object, but should NOT change the equality of that object.
Constructor Summary | |
ArrayHeap(Comparator cmp)
The objects added will be ordered using the Comparator . |
|
ArrayHeap(Comparator cmp,
int initCapacity)
|
Method Summary | |
void |
add(Object o)
Adds an object to the heap. |
void |
clear()
Clears the heap. |
int |
decreaseKey(Object o)
Changes the position of an element o in the heap based on a change in the ordering of o. |
void |
dump()
|
Object |
extractMin()
Finds the object with the minimum key, removes it from the heap, and returns it. |
boolean |
isEmpty()
Checks if the heap is empty. |
Object |
min()
Finds the object with the minimum key and returns it, without modifying the heap. |
int |
size()
Get the number of elements in the heap. |
void |
verify()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ArrayHeap(Comparator cmp)
Comparator
.
public ArrayHeap(Comparator cmp, int initCapacity)
Method Detail |
public Object extractMin()
extractMin
in interface Heap
public Object min()
min
in interface Heap
public void add(Object o)
add
in interface Heap
o
- an Object
valuepublic int decreaseKey(Object o)
decreaseKey
in interface Heap
o
- an Object
value
public boolean isEmpty()
isEmpty
in interface Heap
boolean
valuepublic int size()
size
in interface Heap
int
valuepublic void clear()
public void dump()
public void verify()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |