E - Element type to storepublic class ConcurrentHashIndex<E> extends java.util.AbstractCollection<E> implements Index<E>, java.util.RandomAccess
| Modifier and Type | Field and Description |
|---|---|
static int |
UNKNOWN_ID |
| Constructor and Description |
|---|
ConcurrentHashIndex()
Constructor.
|
ConcurrentHashIndex(int initialCapacity)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E o) |
boolean |
addAll(java.util.Collection<? extends E> c) |
int |
addToIndex(E o)
Takes an Object and returns the integer index of the Object.
|
void |
clear() |
boolean |
contains(java.lang.Object o) |
E |
get(int i)
Gets the object whose index is the integer argument.
|
int |
indexOf(E o)
Returns the integer index of the Object in the Index or -1 if the Object
is not already in the Index.
|
int |
indexOf(E o,
boolean add)
Deprecated.
|
boolean |
isLocked()
Queries the Index for whether it's locked or not.
|
java.util.Iterator<E> |
iterator() |
void |
lock()
Locks the Index.
|
java.util.Collection<E> |
objects(int[] indices)
Looks up the objects corresponding to an array of indices, and returns them in a
Collection. |
java.util.List<E> |
objectsList()
Returns a complete
List of indexed objects, in the order of their indices. |
void |
saveToFilename(java.lang.String s)
Save the contents of this index into a file.
|
void |
saveToWriter(java.io.Writer out)
Save the contents of this index into string form, as part of a larger
text-serialization.
|
int |
size()
Returns the number of indexed objects.
|
java.lang.String |
toString() |
void |
unlock()
Unlocks the Index.
|
containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArraypublic static final int UNKNOWN_ID
public ConcurrentHashIndex()
public ConcurrentHashIndex(int initialCapacity)
initialCapacity - public E get(int i)
Indexpublic int indexOf(E o)
Indexpublic int addToIndex(E o)
IndexaddToIndex in interface Index<E>o - the Object whose index is desired.@Deprecated public int indexOf(E o, boolean add)
Indexpublic boolean add(E o)
public boolean addAll(java.util.Collection<? extends E> c)
public java.util.List<E> objectsList()
IndexList of indexed objects, in the order of their indices.objectsList in interface Index<E>List of indexed objectspublic java.util.Collection<E> objects(int[] indices)
IndexCollection.public boolean isLocked()
Indexpublic void lock()
IndexIndex.add(E) will
leave the Index unchanged and return false).public void unlock()
IndexIndex.add(E) will
leave the Index unchanged and return false).public void saveToWriter(java.io.Writer out)
throws java.io.IOException
IndexsaveToWriter in interface Index<E>out - Writer to save to.java.io.IOException - Exception thrown if cannot save.public void saveToFilename(java.lang.String s)
IndexsaveToFilename in interface Index<E>s - File name.public java.util.Iterator<E> iterator()
public int size()
Indexpublic java.lang.String toString()
toString in class java.util.AbstractCollection<E>public boolean contains(java.lang.Object o)