Package opennlp.tools.util
Class ListHeap<E extends java.lang.Comparable<E>>
- java.lang.Object
-
- opennlp.tools.util.ListHeap<E>
-
- All Implemented Interfaces:
Heap<E>
public class ListHeap<E extends java.lang.Comparable<E>> extends java.lang.Object implements Heap<E>
This class implements the heap interface using aListas 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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(E o)Adds the specified object to the heap.voidclear()Clears the contents of the heap.Eextract()Removes the smallest element from the heap and returns it.Efirst()Returns the smallest element of the heap.booleanisEmpty()Returns whether the heap is empty.java.util.Iterator<E>iterator()Returns an iterator over the elements of the heap.Elast()Returns the largest element of the heap.static voidmain(java.lang.String[] args)Deprecated.intsize()Returns the size of the heap.
-
-
-
Constructor Detail
-
ListHeap
public ListHeap(int sz, java.util.Comparator<E> c)Creates a new heap with the specified size using the sorted based on the specified comparator.- Parameters:
sz- The size of the heap.c- The comparator to be used to sort heap elements.
-
ListHeap
public ListHeap(int sz)
Creates a new heap of the specified size.- Parameters:
sz- The size of the new heap.
-
-
Method Detail
-
size
public int size()
Description copied from interface:HeapReturns the size of the heap.
-
extract
public E extract()
Description copied from interface:HeapRemoves the smallest element from the heap and returns it.
-
first
public E first()
Description copied from interface:HeapReturns the smallest element of the heap.
-
last
public E last()
Description copied from interface:HeapReturns the largest element of the heap.
-
add
public void add(E o)
Description copied from interface:HeapAdds the specified object to the heap.
-
clear
public void clear()
Description copied from interface:HeapClears the contents of the heap.
-
iterator
public java.util.Iterator<E> iterator()
Description copied from interface:HeapReturns an iterator over the elements of the heap. No specific ordering of these elements is guaranteed.
-
isEmpty
public boolean isEmpty()
Description copied from interface:HeapReturns whether the heap is empty.
-
main
@Deprecated public static void main(java.lang.String[] args)
Deprecated.
-
-