E
- public class ConcurrentHashIndex<E> extends AbstractCollection<E> implements Index<E>, 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(Collection<? extends E> c) |
int |
addToIndex(E o)
Takes an Object and returns the integer index of the Object.
|
void |
clear() |
boolean |
contains(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.
|
Iterator<E> |
iterator() |
void |
lock()
Locks the Index.
|
Collection<E> |
objects(int[] indices)
Looks up the objects corresponding to an array of indices, and returns them in a
Collection . |
List<E> |
objectsList()
Returns a complete
List of indexed objects, in the order of their indices. |
void |
saveToFilename(String s)
Save the contents of this index into a file.
|
void |
saveToWriter(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.
|
String |
toString() |
void |
unlock()
Unlocks the Index.
|
containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
equals, hashCode, parallelStream, removeIf, spliterator, stream
public static final int UNKNOWN_ID
public ConcurrentHashIndex()
public ConcurrentHashIndex(int initialCapacity)
initialCapacity
- public E get(int i)
Index
public int indexOf(E o)
Index
public int addToIndex(E o)
Index
addToIndex
in interface Index<E>
o
- the Object whose index is desired.@Deprecated public int indexOf(E o, boolean add)
Index
public boolean add(E o)
add
in interface Index<E>
add
in interface Collection<E>
add
in class AbstractCollection<E>
public boolean addAll(Collection<? extends E> c)
addAll
in interface Index<E>
addAll
in interface Collection<E>
addAll
in class AbstractCollection<E>
public List<E> objectsList()
Index
List
of indexed objects, in the order of their indices.objectsList
in interface Index<E>
List
of indexed objectspublic Collection<E> objects(int[] indices)
Index
Collection
.objects
in interface Index<E>
indices
- An array of indicesCollection
of the objects corresponding to the indices argument.public boolean isLocked()
Index
public void lock()
Index
Index.add(E)
will
leave the Index unchanged and return false
).public void unlock()
Index
Index.add(E)
will
leave the Index unchanged and return false
).public void saveToWriter(Writer out) throws IOException
Index
saveToWriter
in interface Index<E>
out
- Writer to save to.IOException
- Exception thrown if cannot save.public void saveToFilename(String s)
Index
saveToFilename
in interface Index<E>
s
- File name.public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in class AbstractCollection<E>
public int size()
Index
size
in interface Index<E>
size
in interface Collection<E>
size
in class AbstractCollection<E>
public String toString()
toString
in class AbstractCollection<E>
public boolean contains(Object o)
contains
in interface Index<E>
contains
in interface Collection<E>
contains
in class AbstractCollection<E>
public void clear()
clear
in interface Index<E>
clear
in interface Collection<E>
clear
in class AbstractCollection<E>