|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.umn.cs.nlp.NBestList<E>
public class NBestList<E extends Comparable<? super E>>
Represents an n-best list of comparable elements.
Constructor Summary | |
---|---|
NBestList(int capacity)
Construct an NBestList. |
Method Summary | |
---|---|
void |
add(E element)
Attempt to add an element to the NBestList. |
E |
get(int n)
Get the n-th best item in the NBestList. |
E |
getBest()
Get the best element in the NBestList. |
int |
getCapacity()
Get the capacity of the NBestList. |
int |
getSize()
Get the number of elements currently stored in the NBestList. |
static void |
main(String[] args)
|
List<E> |
toList()
Return an unmodifiable view of the underlying list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NBestList(int capacity)
capacity
- maximum number of elements that can be stored in the NBestListMethod Detail |
---|
public int getSize()
public int getCapacity()
public void add(E element)
If this element's value is greater than the worst element in the list, the worst element is removed, and this element is added to the list. Else if getCapacity() > getSize(), this element is added to the list. Else this element is not added to the list.
element
- Element to be added to the listpublic E getBest()
Equivalent to get(1).
public E get(int n)
get(1) will return the best item in the list. get(getSize()-1) will return the worst item in the list.
n
- rank of the element to be retrieved
public List<E> toList()
public static void main(String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |