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
public abstract class HashTable<T> extends Object implements Iterable<T>
A hash table, i.e. a mapping between keys and values involving aHashFunction.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract intcomputeIndex(CharSequence key)Hashes akeyand computes an array index based on that hash.Tget(int index)Tget(CharSequence key)Iterator<T>iterator()voidset(int index, T value)intsize()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
size
public final int size()
- Returns:
- The size of this hash table, i.e. the number of buckets.
-
get
public final T get(CharSequence key)
- Parameters:
key- A key to hash in order to compute an index.- Returns:
- The content of the bucket assigned to the given
key.
-
get
public final T get(int index)
- 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
public final void set(int index, T value)- 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
public abstract int computeIndex(CharSequence key)
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.
-
-