edu.stanford.nlp.util
Class Index
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--edu.stanford.nlp.util.Index
- All Implemented Interfaces:
- Collection, List
- public class Index
- extends AbstractList
Index is a list which maps between an Object vocabulary and
contiguous integer indices. It supports constant-time lookup in
both directions.
The typical usage would be:
Index index = new Index(collection);
followed by
int i = index.indexOf(object);
or
Object o = index.get(i);
The source contains a concrete example of use.
- Since:
- 1.0
- Author:
- Dan Klein
- See Also:
AbstractList
Methods inherited from class java.util.AbstractList |
add, addAll, clear, equals, hashCode, iterator, listIterator, listIterator, remove, removeRange, set |
objects
protected List objects
indexes
protected Map indexes
locked
protected boolean locked
Index
public Index()
Index
public Index(Collection c)
indices
public int[] indices(List elems)
- Returns the index of each elem in an array.
size
public int size()
- Specified by:
size
in interface List
- Specified by:
size
in class AbstractCollection
get
public Object get(int i)
- Specified by:
get
in interface List
- Specified by:
get
in class AbstractList
isLocked
public boolean isLocked()
lock
public void lock()
unlock
public void unlock()
indexOf
public int indexOf(Object o)
- Specified by:
indexOf
in interface List
- Overrides:
indexOf
in class AbstractList
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOf
in interface List
- Overrides:
lastIndexOf
in class AbstractList
addAll
public boolean addAll(Collection c)
- Specified by:
addAll
in interface List
- Overrides:
addAll
in class AbstractCollection
subList
public List subList(int from,
int to)
- Specified by:
subList
in interface List
- Overrides:
subList
in class AbstractList
add
public boolean add(Object o)
- Specified by:
add
in interface List
- Overrides:
add
in class AbstractList
contains
public boolean contains(Object o)
- Specified by:
contains
in interface List
- Overrides:
contains
in class AbstractCollection
main
public static void main(String[] args)
Stanford NLP Group