|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
edu.stanford.nlp.util.Index<E>
public class Index<E>
An Index is a list which maps between an Object vocabulary and a
contiguous non-negative integer index beginning (inclusively) at 0. 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.
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 java.util.Map<E,java.lang.Integer> |
indexes
|
protected boolean |
locked
|
protected java.util.List<E> |
objects
|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
Index()
|
|
Index(java.util.Collection<? extends E> c)
|
Method Summary | |
---|---|
boolean |
add(E o)
Adds an object to the Index. |
boolean |
addAll(java.util.Collection<? extends E> c)
|
void |
clear()
Clears this Index. |
boolean |
contains(java.lang.Object o)
|
static Index |
deserializeReadable(java.lang.String file)
|
E |
get(int i)
|
int |
indexOf(java.lang.Object o)
|
int[] |
indices(java.util.List<E> elems)
Returns the index of each elem in an array. |
boolean |
isLocked()
|
int |
lastIndexOf(java.lang.Object o)
|
void |
lock()
|
static void |
main(java.lang.String[] args)
|
java.util.List<E> |
objectsList()
|
void |
serializeReadable(java.lang.String file)
|
int |
size()
|
java.util.List<E> |
subList(int from,
int to)
|
void |
unlock()
|
Methods inherited from class java.util.AbstractList |
---|
add, addAll, 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 java.util.List<E> objects
protected java.util.Map<E,java.lang.Integer> indexes
protected boolean locked
Constructor Detail |
---|
public Index()
public Index(java.util.Collection<? extends E> c)
Method Detail |
---|
public void clear()
clear
in interface java.util.Collection<E>
clear
in interface java.util.List<E>
clear
in class java.util.AbstractList<E>
public int[] indices(java.util.List<E> elems)
public int size()
size
in interface java.util.Collection<E>
size
in interface java.util.List<E>
size
in class java.util.AbstractCollection<E>
public E get(int i)
get
in interface java.util.List<E>
get
in class java.util.AbstractList<E>
public java.util.List<E> objectsList()
public boolean isLocked()
public void lock()
public void unlock()
public int indexOf(java.lang.Object o)
indexOf
in interface java.util.List<E>
indexOf
in class java.util.AbstractList<E>
public int lastIndexOf(java.lang.Object o)
lastIndexOf
in interface java.util.List<E>
lastIndexOf
in class java.util.AbstractList<E>
public boolean addAll(java.util.Collection<? extends E> c)
addAll
in interface java.util.Collection<E>
addAll
in interface java.util.List<E>
addAll
in class java.util.AbstractCollection<E>
public java.util.List<E> subList(int from, int to)
subList
in interface java.util.List<E>
subList
in class java.util.AbstractList<E>
public boolean add(E o)
add
in interface java.util.Collection<E>
add
in interface java.util.List<E>
add
in class java.util.AbstractList<E>
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<E>
contains
in interface java.util.List<E>
contains
in class java.util.AbstractCollection<E>
public void serializeReadable(java.lang.String file)
public static Index deserializeReadable(java.lang.String file)
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |