|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.berkeley.nlp.lm.collections.Indexer<E>
public class Indexer<E extends Comparable<E>>
Maintains a two-way map between a set of objects and contiguous integers from 0 to the number of objects.
Field Summary | |
---|---|
protected TIntMap<E> |
indexes
|
protected boolean |
locked
|
protected ArrayList<E> |
objects
|
Constructor Summary | |
---|---|
Indexer()
|
|
Indexer(boolean sync)
|
|
Indexer(Collection<? extends E> c)
|
Method Summary | |
---|---|
boolean |
add(E elem)
|
int |
getIndex(E e)
Return the index of the element If doesn't exist, add it. |
E |
getObject(int index)
|
Iterable<E> |
getObjects()
|
int |
indexOf(E o)
Returns the index of the given object, or -1 if the object is not present in the indexer. |
void |
lock()
|
int |
size()
Returns the number of objects indexed. |
void |
trim()
Save some space my compacting underlying maps and lists. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ArrayList<E extends Comparable<E>> objects
protected TIntMap<E extends Comparable<E>> indexes
protected boolean locked
Constructor Detail |
---|
public Indexer(boolean sync)
public Indexer()
public Indexer(Collection<? extends E> c)
Method Detail |
---|
public void lock()
public E getObject(int index)
public boolean add(E elem)
public int size()
public int indexOf(E o)
o
-
public int getIndex(E e)
public void trim()
public Iterable<E> getObjects()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |