public class ProbeHashMap<K,V> extends AbstractHashMap<K,V>
AbstractMap.MapEntry<K,V>
capacity, n
Constructor and Description |
---|
ProbeHashMap()
Creates a hash table with capacity 17 and prime factor 109345121.
|
ProbeHashMap(int cap)
Creates a hash table with given capacity and prime factor 109345121.
|
ProbeHashMap(int cap,
int p)
Creates a hash table with the given capacity and prime factor.
|
Modifier and Type | Method and Description |
---|---|
protected V |
bucketGet(int h,
K k)
Returns value associated with key k in bucket with hash value h.
|
protected V |
bucketPut(int h,
K k,
V v)
Associates key k with value v in bucket with hash value h, returning
the previously associated value, if any.
|
protected V |
bucketRemove(int h,
K k)
Removes entry having key k from bucket with hash value h, returning
the previously associated value, if found.
|
protected void |
createTable()
Creates an empty table having length equal to current capacity.
|
Iterable<Entry<K,V>> |
entrySet()
Returns an iterable collection of all key-value entries of the map.
|
get, put, remove, size
isEmpty, keySet, values
public ProbeHashMap()
public ProbeHashMap(int cap)
public ProbeHashMap(int cap, int p)
protected void createTable()
createTable
in class AbstractHashMap<K,V>
protected V bucketGet(int h, K k)
bucketGet
in class AbstractHashMap<K,V>
h
- the hash value of the relevant bucketk
- the key of interestprotected V bucketPut(int h, K k, V v)
bucketPut
in class AbstractHashMap<K,V>
h
- the hash value of the relevant bucketk
- the key of interestv
- the value to be associatedprotected V bucketRemove(int h, K k)
bucketRemove
in class AbstractHashMap<K,V>
h
- the hash value of the relevant bucketk
- the key of interest