K
- the type of keys this index is ordered byT
- the type of objects stored in this collectionpublic class IntStorageIndex<K,T> extends AbstractArrayIndex<K,T> implements java.io.Serializable
storage with integer addresses
.
The addresses provided by the storage are kept in internal sorted array
that allows fast access to data in the storage. Objects are indexed
according to the given IndexComparator
.Constructor and Description |
---|
IntStorageIndex(IntStorage<T> storage,
IndexComparator<K,T> comparator)
Creates a new instance of IntStorageIndex for the specified storage.
|
Modifier and Type | Method and Description |
---|---|
protected Lock |
acquireSearchLock()
Locks this index for searching and returns a lock object if it is supported.
|
boolean |
add(T object)
Adds the specified object to this instance.
|
IndexComparator<K,T> |
comparator()
Returns the comparator that defines order of this index.
|
protected int |
compare(K key,
T object)
Compares its two arguments for order.
|
void |
destroy()
Destroy this index.
|
void |
finalize()
Finalize this index.
|
protected T |
get(int i)
Returns the element at the specified position in this collection.
|
protected int |
insertionPoint(T object)
Searches for the point where to insert the object
object . |
protected boolean |
remove(int i)
Removes the element at the specified position in this collection.
|
int |
size()
Returns the number of elements in this collection.
|
search, search, search, search, search, search, search, search
binarySearch, first, fullSearch, indexOf, last, mergeSort
public IntStorageIndex(IntStorage<T> storage, IndexComparator<K,T> comparator)
storage
- the storage to associate with this indexcomparator
- the comparator imposing natural order of this indexpublic void finalize() throws java.lang.Throwable
ModifiableIndex
finalize
in interface ModifiableIndex<T>
finalize
in class AbstractArrayIndex<K,T>
java.lang.Throwable
- if there was an error while cleaningpublic void destroy() throws java.lang.Throwable
ModifiableIndex
destroy
in interface ModifiableIndex<T>
java.lang.Throwable
- if there was an error while cleaningpublic IndexComparator<K,T> comparator()
OrderedIndex
comparator
in interface OrderedIndex<K,T>
protected int compare(K key, T object) throws java.lang.ClassCastException
SortedArrayData
compare
in class SortedArrayData<K,T>
key
- the key to indexCompareobject
- the object to be comparedjava.lang.ClassCastException
- if the arguments' types prevent them from
being compared by this comparator.public int size()
SortedArrayData
protected int insertionPoint(T object) throws BucketStorageException
object
.object
- the object to insertBucketStorageException
- if there was a problem determining the pointpublic boolean add(T object) throws BucketStorageException
Addible
add
in interface Addible<T>
object
- the object to be addedBucketStorageException
- if there was an error adding the objectprotected boolean remove(int i)
AbstractArrayIndex
remove
in class AbstractArrayIndex<K,T>
i
- index of the element to removeprotected T get(int i) throws java.lang.IndexOutOfBoundsException, java.lang.IllegalStateException
SortedArrayData
get
in class SortedArrayData<K,T>
i
- index of the element to returnjava.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())java.lang.IllegalStateException
- if the object at position index
cannot be accessedprotected Lock acquireSearchLock()
AbstractArrayIndex
Lock.unlock()
method if this method has returned non-null.acquireSearchLock
in class AbstractArrayIndex<K,T>