Package edu.berkeley.nlp.lm.collections
Class Indexer<E extends Comparable<E>>
java.lang.Object
edu.berkeley.nlp.lm.collections.Indexer<E>
- All Implemented Interfaces:
Serializable
Maintains a two-way map between a set of objects and contiguous integers from
0 to the number of objects.
- Author:
- Dan Klein, Adam Pauls
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
Return the index of the element If doesn't exist, add it.getObject
(int index) int
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.
-
Field Details
-
objects
-
indexes
-
locked
protected boolean locked
-
-
Constructor Details
-
Indexer
public Indexer(boolean sync) -
Indexer
public Indexer() -
Indexer
-
-
Method Details
-
lock
public void lock() -
getObject
-
add
-
size
public int size()Returns the number of objects indexed. -
indexOf
Returns the index of the given object, or -1 if the object is not present in the indexer.- Parameters:
o
-- Returns:
-
getIndex
Return the index of the element If doesn't exist, add it. -
trim
public void trim()Save some space my compacting underlying maps and lists. -
getObjects
-