public interface KeyIndex
Bidirectional mapping between long keys and a contiguous range of integer indexes.
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(long key)
Query whether this index contains a particular key.
|
KeyIndex |
frozenCopy()
Get a frozen copy of this key index.
|
int |
getIndex(long key)
Get the index of a key.
|
long |
getKey(int idx)
Get the key for an index position.
|
LongList |
getKeyList()
Get the list of indexed keys.
|
int |
getLowerBound()
Get the lower bound of the index range for this index.
|
int |
getUpperBound()
Get the upper bound of the index range for this index.
|
int |
size()
Get the size of this index.
|
int |
tryGetIndex(long id)
Try to get the index for an ID, returning a negative value if it does not exist.
|
int getIndex(long key)
Get the index of a key.
key
- The key to query.IllegalArgumentException
- if key
is not in the index.boolean containsKey(long key)
Query whether this index contains a particular key.
key
- The key to look for.true
if the index contains the key.long getKey(int idx)
Get the key for an index position.
idx
- The index of the key to retrieve.IndexOutOfBoundsException
- if idx
is not a valid index.int tryGetIndex(long id)
Try to get the index for an ID, returning a negative value if it does not exist. This method is like getIndex(long)
, except it returns a negative value instead of throwing an exception if the id does not exist.
id
- The ID to look for.int size()
Get the size of this index.
int getLowerBound()
Get the lower bound of the index range for this index.
int getUpperBound()
Get the upper bound of the index range for this index.
LongList getKeyList()
Get the list of indexed keys. This list is 0-indexed, so the key at position 0 in this list is at index getLowerBound()
in the key index.
KeyIndex frozenCopy()
Get a frozen copy of this key index. If the key index is mutable, then this method will return an immutable copy of it. If the key index is already immutable, it may just return itself without copying.