public final class FrozenHashKeyIndex extends java.lang.Object implements KeyIndex, java.io.Serializable
Immutable key index backed by a hash table.
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsKey(long id)
Query whether this index contains a particular key.
|
static FrozenHashKeyIndex |
create(LongCollection keys)
Create a new key index.
|
static FrozenHashKeyIndex |
create(LongList keys)
Construct a new key index.
|
FrozenHashKeyIndex |
frozenCopy()
Get a frozen copy of this key index.
|
int |
getIndex(long id)
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.
|
public static FrozenHashKeyIndex create(LongList keys)
Construct a new key index. It maps each long key to its position in the list.
keys - The list of keys to store.public static FrozenHashKeyIndex create(LongCollection keys)
Create a new key index.
keys - The keys.keys.public int getIndex(long id)
KeyIndexGet the index of a key.
public boolean containsKey(long id)
KeyIndexQuery whether this index contains a particular key.
containsKey in interface KeyIndexid - The key to look for.true if the index contains the key.public long getKey(int idx)
KeyIndexGet the key for an index position.
public LongList getKeyList()
KeyIndexGet the list of indexed keys. This list is 0-indexed, so the key at position 0 in this list is at index KeyIndex.getLowerBound() in the key index.
getKeyList in interface KeyIndexpublic int tryGetIndex(long id)
KeyIndexTry to get the index for an ID, returning a negative value if it does not exist. This method is like KeyIndex.getIndex(long), except it returns a negative value instead of throwing an exception if the id does not exist.
tryGetIndex in interface KeyIndexid - The ID to look for.public int size()
KeyIndexGet the size of this index.
public int getLowerBound()
KeyIndexGet the lower bound of the index range for this index.
getLowerBound in interface KeyIndexpublic int getUpperBound()
KeyIndexGet the upper bound of the index range for this index.
getUpperBound in interface KeyIndexpublic FrozenHashKeyIndex frozenCopy()
KeyIndexGet 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.
frozenCopy in interface KeyIndex