|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectopennlp.tools.util.ListHeap
public class ListHeap
This class implements the heap interface using a List as the underlying
data structure. This heap allows values which are equals to be inserted. The heap will
return the top K values which have been added where K is specified by the size passed to
the constructor. K+1 values are not gaurenteed to be kept in the heap or returned in a
particular order.
| Constructor Summary | |
|---|---|
ListHeap(int sz)
Creates a new heap of the specified size. |
|
ListHeap(int sz,
java.util.Comparator c)
Creates a new heap with the specified size using the sorted based on the specified comparator. |
|
| Method Summary | |
|---|---|
void |
add(java.lang.Object o)
Adds the specified object to the heap. |
void |
clear()
Clears the contents of the heap. |
java.lang.Object |
extract()
Removes the smallest element from the heap and returns it. |
java.lang.Object |
first()
Returns the smallest element of the heap. |
boolean |
isEmpty()
Returns whether the heap is empty. |
java.util.Iterator |
iterator()
Returns an iterator over the elements of the heap. |
java.lang.Object |
last()
Returns the largest element of the heap. |
static void |
main(java.lang.String[] args)
|
int |
size()
Returns the size of the heap. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ListHeap(int sz,
java.util.Comparator c)
sz - The size of the heap.c - The comparator to be used to sort heap elements.public ListHeap(int sz)
sz - The size of the new heap.| Method Detail |
|---|
public int size()
Heap
size in interface Heappublic java.lang.Object extract()
Heap
extract in interface Heappublic java.lang.Object first()
Heap
first in interface Heappublic java.lang.Object last()
Heap
last in interface Heappublic void add(java.lang.Object o)
Heap
add in interface Heapo - The object to add to the heap.public void clear()
Heap
clear in interface Heappublic java.util.Iterator iterator()
Heap
iterator in interface Heappublic boolean isEmpty()
Heap
isEmpty in interface Heappublic static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||