|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection
java.util.AbstractSet
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 | |
boolean |
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. |
Iterator |
iterator()
Returns an iterator over its elements, in order. |
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.util.AbstractSet |
equals, hashCode, removeAll |
Methods inherited from class java.util.AbstractCollection |
addAll, contains, containsAll, remove, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Set |
addAll, contains, containsAll, remove, retainAll, toArray, toArray |
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 boolean 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 Iterator iterator()
Heap
iterator
in interface Heap
public void clear()
clear
in interface Set
public void dump()
public void verify()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |