Class HashTable<T>
java.lang.Object
org.hibernate.search.util.common.data.impl.HashTable<T>
- Type Parameters:
T- The type of elements stored in each bucket.
- All Implemented Interfaces:
Iterable<T>
- Direct Known Subclasses:
ModuloHashTable,RangeHashTable
A hash table, i.e. a mapping between keys and values involving a
HashFunction.-
Method Summary
Modifier and TypeMethodDescriptionabstract intcomputeIndex(CharSequence key) Hashes akeyand computes an array index based on that hash.final Tget(int index) final Tget(CharSequence key) iterator()final voidfinal intsize()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
size
public final int size()- Returns:
- The size of this hash table, i.e. the number of buckets.
-
iterator
-
get
- Parameters:
key- A key to hash in order to compute an index.- Returns:
- The content of the bucket assigned to the given
key.
-
get
- Parameters:
index- The index of a bucket in this hash table.- Returns:
- The content of the bucket at index
index. - Throws:
ArrayIndexOutOfBoundsException- If the given index is negative or higher than the table's size.
-
set
- Parameters:
index- The index of a bucket in this hash table.value- The value to set for the bucket at indexindex.- Throws:
ArrayIndexOutOfBoundsException- If the given index is negative or higher than the table's size.
-
computeIndex
Hashes akeyand computes an array index based on that hash.The maximum index is defined by constructor parameters passed to the hash function.
- Parameters:
key- A key to hash in order to compute an index.- Returns:
- The index to use for the given
keyin a hash table of sizesize.
-