T
- class of stored elementspublic class CuckooHashing<T> extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_NUM_TABLES |
static int |
DEFAULT_STASH_SIZE |
Constructor and 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.
|
Modifier and Type | Method and 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()
Returns
true 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.
|
public static final int DEFAULT_STASH_SIZE
public static final int DEFAULT_NUM_TABLES
public CuckooHashing(int startHashSize, int maxStashSize, int startNumTables, Random random)
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 numberspublic CuckooHashing(int hashSize, Random random)
hashSize
- size of the hash functionrandom
- instance to generate a stream of pseudorandom numberspublic void put(long key, T element)
key
- key value of the elementelement
- value of the elementpublic T get(long key)
key
- key value of the elementpublic void clear()
public int size()
public boolean isEmpty()
true
if this hash table contains no elements.true
if this hash table contains no elementsCopyright © 2019 University of Waikato, Hamilton, NZ. All Rights Reserved.