|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmessif.utility.SortedArrayData<K,T>
messif.buckets.index.impl.AbstractArrayIndex<K,T>
K
- the type of keys this index is ordered byT
- the type of objects stored in this indexpublic abstract class AbstractArrayIndex<K,T>
Implementation of index that stores the indexed data in a sorted array.
Access to the actual array is abstract through the add
,
remove
and get
methods.
All search methods are correctly implemented using binary search on the array whenever possible.
Constructor Summary | |
---|---|
AbstractArrayIndex()
|
Method Summary | ||
---|---|---|
protected abstract Lock |
acquireSearchLock()
Locks this index for searching and returns a lock object if it is supported. |
|
void |
finalize()
Finalize this index. |
|
protected abstract boolean |
remove(int index)
Removes the element at the specified position in this collection. |
|
ModifiableSearch<T> |
search()
Returns a search for all objects in this index. |
|
ModifiableSearch<T> |
search(java.util.Collection<? extends K> keys)
Returns a search for objects in this index using the internal OrderedIndex.comparator() of this index. |
|
|
search(IndexComparator<? super C,? super T> comparator,
C key)
Returns a search for objects in this index that have any of the specified keys. |
|
|
search(IndexComparator<? super C,? super T> comparator,
C from,
C to)
Returns a search for objects in this index that are within the specified key-range. |
|
|
search(IndexComparator<? super C,? super T> comparator,
java.util.Collection<? extends C> keys)
Returns a search for objects in this index that have any of the specified keys. |
|
ModifiableSearch<T> |
search(K key,
boolean restrictEqual)
Returns a search for objects in this index using the internal OrderedIndex.comparator() of this index. |
|
ModifiableSearch<T> |
search(K from,
K to)
Returns a search for objects in this index using the internal OrderedIndex.comparator() of this index. |
|
ModifiableSearch<T> |
search(K startKey,
K from,
K to)
Returns a search for objects in this index using the internal OrderedIndex.comparator() of this index. |
Methods inherited from class messif.utility.SortedArrayData |
---|
binarySearch, compare, first, fullSearch, get, indexOf, last, mergeSort, size |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface messif.buckets.index.OrderedIndex |
---|
comparator |
Methods inherited from interface messif.buckets.index.ModifiableIndex |
---|
destroy |
Methods inherited from interface messif.buckets.index.Index |
---|
size |
Methods inherited from interface messif.buckets.Addible |
---|
add |
Constructor Detail |
---|
public AbstractArrayIndex()
Method Detail |
---|
protected abstract boolean remove(int index)
index
- index of the element to remove
protected abstract Lock acquireSearchLock()
Lock.unlock()
method if this method has returned non-null.
public void finalize() throws java.lang.Throwable
ModifiableIndex
finalize
in interface ModifiableIndex<T>
finalize
in class java.lang.Object
java.lang.Throwable
- if there was an error while cleaningpublic final ModifiableSearch<T> search() throws java.lang.IllegalStateException
Index
search
in interface Index<T>
search
in interface ModifiableIndex<T>
java.lang.IllegalStateException
- if there was an error initializing the search on this indexpublic final ModifiableSearch<T> search(K key, boolean restrictEqual) throws java.lang.IllegalStateException
OrderedIndex
OrderedIndex.comparator()
of this index.
If the restrictEqual
is true, the search returns only
objects that are comparator-equal to key
.
Objects are returned in the order defined by this index.
search
in interface ModifiableOrderedIndex<K,T>
search
in interface OrderedIndex<K,T>
key
- the key to search forrestrictEqual
- if true, the search is restricted
only to objects that are comparator-equal to key
java.lang.IllegalStateException
- if there was an error initializing the search on this indexpublic final ModifiableSearch<T> search(K from, K to) throws java.lang.IllegalStateException
OrderedIndex
OrderedIndex.comparator()
of this index.
All objects from the interval [from, to]
are returned. If a null
value is specified as a boundary, that bound is not restricted. That means that
search(x, null)
will return all objects from this index that are bigger than
or equal to x
.
Objects are returned in the order defined by this index.
search
in interface ModifiableOrderedIndex<K,T>
search
in interface OrderedIndex<K,T>
from
- the lower bound on the searched objects, i.e. objects greater or equal are returnedto
- the upper bound on the searched objects, i.e. objects smaller or equal are returned
java.lang.IllegalStateException
- if there was an error initializing the search on this indexpublic final ModifiableSearch<T> search(K startKey, K from, K to) throws java.lang.IllegalStateException
OrderedIndex
OrderedIndex.comparator()
of this index.
All objects from the interval [from, to]
are returned. Search
starts at the object nearest to the given startKey
. If a null
value is specified as a boundary, that bound is not restricted. That means that
search(start, x, null)
will return all objects from this index that are bigger than
or equal to x
starting at object with key start
.
Objects are returned in the order defined by this index.
search
in interface ModifiableOrderedIndex<K,T>
search
in interface OrderedIndex<K,T>
startKey
- the key from which to start the searchfrom
- the lower bound on the searched objects, i.e. objects greater or equal are returnedto
- the upper bound on the searched objects, i.e. objects smaller or equal are returned
java.lang.IllegalStateException
- if there was an error initializing the search on this indexpublic final ModifiableSearch<T> search(java.util.Collection<? extends K> keys) throws java.lang.IllegalStateException
OrderedIndex
OrderedIndex.comparator()
of this index.
All objects that are comparator
-equal to any of the given keys
are returned.
Objects are returned in the order defined by this index.
search
in interface ModifiableOrderedIndex<K,T>
search
in interface OrderedIndex<K,T>
keys
- the keys to search for
java.lang.IllegalStateException
- if there was an error initializing the search on this indexpublic final <C> ModifiableSearch<T> search(IndexComparator<? super C,? super T> comparator, C key) throws java.lang.IllegalStateException
Index
key
need not necessarily be of the same class as the objects stored
in this index and also consistency with equals
is not required.
Note that objects are not necessarily returned in the order defined by the comparator
search
in interface Index<T>
search
in interface ModifiableIndex<T>
C
- the type of the key used by the searchcomparator
- compares the key
with the stored objectskey
- the key to search for
java.lang.IllegalStateException
- if there was an error initializing the search on this indexpublic final <C> ModifiableSearch<T> search(IndexComparator<? super C,? super T> comparator, C from, C to) throws java.lang.IllegalStateException
Index
[from, to]
need not necessarily be of the same
class as the objects stored in this index, however, the comparator must be
able to compare the boundaries and the internal objects.
Note that objects are not returned in the order defined by the comparator
search
in interface Index<T>
search
in interface ModifiableIndex<T>
C
- the type the boundaries used by the searchcomparator
- compares the boundaries [from, to]
with the stored objectsfrom
- the lower bound on the searched objects, i.e. objects greater or equal are returnedto
- the upper bound on the searched objects, i.e. objects smaller or equal are returned
java.lang.IllegalStateException
- if there was an error initializing the search on this indexpublic final <C> ModifiableSearch<T> search(IndexComparator<? super C,? super T> comparator, java.util.Collection<? extends C> keys) throws java.lang.IllegalStateException
Index
key
need not necessarily be of the same class as the objects stored
in this index and also consistency with equals
is not required.
Note that objects are not necessarily returned in the order defined by the comparator
search
in interface Index<T>
search
in interface ModifiableIndex<T>
C
- the type of the keys used by the searchcomparator
- compares the keys
with the stored objectskeys
- the keys to search for (at least one key must be given)
java.lang.IllegalStateException
- if there was an error initializing the search on this index
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |