Package moa.clusterers.kmeanspm
Class CuckooHashing<T>
- java.lang.Object
-
- moa.clusterers.kmeanspm.CuckooHashing<T>
-
- Type Parameters:
T
- class of stored elements
public class CuckooHashing<T> extends Object
Provides a hash table based on Cuckoo Hashing. Citation: Rasmus Pagh, Flemming Friche Rodler: Cuckoo Hashing. ESA 2001: 121-133
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_NUM_TABLES
static int
DEFAULT_STASH_SIZE
-
Constructor Summary
Constructors Constructor Description CuckooHashing(int startHashSize, int maxStashSize, int startNumTables, Random random)
Creates a new hash table based on Cuckoo Hashing.CuckooHashing(int hashSize, Random random)
Creates a new hash table based on Cuckoo Hashing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Removes all of the elements from this hash table.T
get(long key)
Gets an element of the hash table.boolean
isEmpty()
Returnstrue
if this hash table contains no elements.void
put(long key, T element)
Adds an element to the hash table.int
size()
Returns the number of elements in the hash table.
-
-
-
Field Detail
-
DEFAULT_STASH_SIZE
public static final int DEFAULT_STASH_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_NUM_TABLES
public static final int DEFAULT_NUM_TABLES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CuckooHashing
public CuckooHashing(int startHashSize, int maxStashSize, int startNumTables, Random random)
Creates a new hash table based on Cuckoo Hashing.- Parameters:
startHashSize
- size of the hash function at the beginning (must be smaller than 31)maxStashSize
- maximum size of the stashstartNumTables
- number of tables for Cuckoo hashingrandom
- instance to generate a stream of pseudorandom numbers
-
CuckooHashing
public CuckooHashing(int hashSize, Random random)
Creates a new hash table based on Cuckoo Hashing.- Parameters:
hashSize
- size of the hash functionrandom
- instance to generate a stream of pseudorandom numbers
-
-
Method Detail
-
put
public void put(long key, T element)
Adds an element to the hash table.- Parameters:
key
- key value of the elementelement
- value of the element
-
get
public T get(long key)
Gets an element of the hash table.- Parameters:
key
- key value of the element
-
clear
public void clear()
Removes all of the elements from this hash table. The hash table will be empty after this call returns.
-
size
public int size()
Returns the number of elements in the hash table.- Returns:
- the number of elements in the hash table
-
isEmpty
public boolean isEmpty()
Returnstrue
if this hash table contains no elements.- Returns:
true
if this hash table contains no elements
-
-