|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection
java.util.AbstractList
edu.stanford.nlp.util.Index
An Index is a list which maps between an Object vocabulary and
contiguous integer indices. It supports constant-time lookup in
both directions (via get(int)
and indexOf(Object)
.
The indexOf(Object)
method compares objects by
equals
, as other Collections.
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 as the main method.
An Index can be locked or unlocked: a locked index cannot have new items added to it.
AbstractList
,
Serialized FormField Summary | |
protected Map |
indexes
|
protected boolean |
locked
|
protected List |
objects
|
Fields inherited from class java.util.AbstractList |
modCount |
Constructor Summary | |
Index()
|
|
Index(Collection c)
|
Method Summary | |
boolean |
add(Object o)
Adds an object to the Index. |
boolean |
addAll(Collection c)
|
boolean |
contains(Object o)
|
Object |
get(int i)
|
int |
indexOf(Object o)
|
int[] |
indices(List elems)
Returns the index of each elem in an array. |
boolean |
isLocked()
|
int |
lastIndexOf(Object o)
|
void |
lock()
|
static void |
main(String[] args)
|
int |
size()
|
List |
subList(int from,
int to)
|
void |
unlock()
|
Methods inherited from class java.util.AbstractList |
add, addAll, clear, equals, hashCode, iterator, listIterator, listIterator, remove, removeRange, set |
Methods inherited from class java.util.AbstractCollection |
containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
Field Detail |
protected List objects
protected Map indexes
protected boolean locked
Constructor Detail |
public Index()
public Index(Collection c)
Method Detail |
public int[] indices(List elems)
public int size()
size
in interface List
public Object get(int i)
get
in interface List
public boolean isLocked()
public void lock()
public void unlock()
public int indexOf(Object o)
indexOf
in interface List
public int lastIndexOf(Object o)
lastIndexOf
in interface List
public boolean addAll(Collection c)
addAll
in interface List
public List subList(int from, int to)
subList
in interface List
public boolean add(Object o)
add
in interface List
public boolean contains(Object o)
contains
in interface List
public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |