Package com.zybooks.dsaj.map
Class ProbeHashMap<K,V> 
java.lang.Object
com.zybooks.dsaj.map.AbstractMap<K,V>
 
com.zybooks.dsaj.map.AbstractHashMap<K,V>
 
com.zybooks.dsaj.map.ProbeHashMap<K,V> 
- Type Parameters:
- K- The key type (keys must be unique and hashable)
- V- The value type
- All Implemented Interfaces:
- Map<K,- V> 
Map implementation using hash table with linear probing.
- 
Nested Class SummaryNested classes/interfaces inherited from class com.zybooks.dsaj.map.AbstractMapAbstractMap.MapEntry<K,V> 
- 
Field SummaryFields inherited from class com.zybooks.dsaj.map.AbstractHashMapcapacity, n
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a hash table with capacity 17 and prime factor 109345121.ProbeHashMap(int cap) Creates a hash table with given capacity and prime number 109345121.ProbeHashMap(int cap, int p) Creates a hash table.
- 
Method SummaryModifier and TypeMethodDescriptionprotected VReturns value associated with key k in bucket with hash value h.protected VAssociates key k with value v in bucket with hash value h, returning the previously associated value, if any.protected VbucketRemove(int h, K k) Removes entry having key k from bucket with hash value h, returning the previously associated value, if found.protected voidCreates an empty table having length equal to current capacity.entrySet()Returns an iterable collection of all key-value entries of the map.Methods inherited from class com.zybooks.dsaj.map.AbstractHashMapget, put, remove, sizeMethods inherited from class com.zybooks.dsaj.map.AbstractMapisEmpty, keySet, values
- 
Constructor Details- 
ProbeHashMappublic ProbeHashMap()Creates a hash table with capacity 17 and prime factor 109345121.
- 
ProbeHashMappublic ProbeHashMap(int cap) Creates a hash table with given capacity and prime number 109345121.- Parameters:
- cap- the initial length of the hash table
 
- 
ProbeHashMappublic ProbeHashMap(int cap, int p) Creates a hash table.- Parameters:
- cap- the initial length of the hash table
- p- a prime number used for the hash function
 
 
- 
- 
Method Details- 
createTableprotected void createTable()Creates an empty table having length equal to current capacity.- Specified by:
- createTablein class- AbstractHashMap<K,- V> 
 
- 
bucketGetReturns value associated with key k in bucket with hash value h. If no such entry exists, returns null.- Specified by:
- bucketGetin class- AbstractHashMap<K,- V> 
- Parameters:
- h- the hash value of the relevant bucket
- k- the key of interest
- Returns:
- associate value (or null, if no such entry)
 
- 
bucketPutAssociates key k with value v in bucket with hash value h, returning the previously associated value, if any.- Specified by:
- bucketPutin class- AbstractHashMap<K,- V> 
- Parameters:
- h- the hash value of the relevant bucket
- k- the key of interest
- v- the value to be associated
- Returns:
- previous value associated with k (or null, if no such entry)
 
- 
bucketRemoveRemoves entry having key k from bucket with hash value h, returning the previously associated value, if found.- Specified by:
- bucketRemovein class- AbstractHashMap<K,- V> 
- Parameters:
- h- the hash value of the relevant bucket
- k- the key of interest
- Returns:
- previous value associated with k (or null, if no such entry)
 
- 
entrySetReturns an iterable collection of all key-value entries of the map.- Returns:
- iterable collection of the map's entries
 
 
-