Package dsa.lab05.solutions
Class ChainingHashMap<Key,Value> 
java.lang.Object
dsa.lab05.solutions.ChainingHashMap<Key,Value> 
- Type Parameters:
- Key- the key type
- Value- the value type
- All Implemented Interfaces:
- Container<MapItem<Key,,- Value>> - Map<Key,,- Value> - Iterable<MapItem<Key,- Value>> 
A chaining hash map.
- 
Constructor SummaryConstructorsConstructorDescriptionConstruct an empty chaining hash map.ChainingHashMap(MapItem<Key, Value>... items) Construct a chaining hash map containing the given items.ChainingHashMap(Iterable<MapItem<Key, Value>> items) Construct a chaining hash map containing the given items.ChainingHashMap(Iterable<MapItem<Key, Value>> items, int size) Construct a chaining hash map containing the given items more efficiently thanChainingHashMap(Iterable).
- 
Method SummaryMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliteratorMethods inherited from interface dsa.lab04.base.MapcontainsKey, containsValue, get, insert, keys, values
- 
Constructor Details- 
ChainingHashMappublic ChainingHashMap()Construct an empty chaining hash map.
- 
ChainingHashMapConstruct a chaining hash map containing the given items.- Parameters:
- items- the items
 
- 
ChainingHashMappublic ChainingHashMap(Iterable<MapItem<Key, Value>> items, int size) throws IllegalArgumentExceptionConstruct a chaining hash map containing the given items more efficiently thanChainingHashMap(Iterable).- Parameters:
- items- the items
- size- the number of items
- Throws:
- IllegalArgumentException- if- size!=- n(where- nis- items's size)
 
- 
ChainingHashMapConstruct a chaining hash map containing the given items.- Parameters:
- items- the items
 
 
- 
- 
Method Details- 
sizepublic int size()Description copied from interface:ContainerGet the number of contained items.
- 
findDescription copied from interface:MapFind the item with the given key.- Specified by:
- findin interface- Map<Key,- Value> 
- Parameters:
- key- the item's key
- Returns:
- the item
- Throws:
- NoSuchElementException- if no item has key- key
 
- 
insertDescription copied from interface:MapInsert the given item.If there's already an item with the same key, that item is replaced with this one. This means that if the key was not already contained, the size is incremented, otherwise it isn't. 
- 
removeDescription copied from interface:MapRemove and return the item with the given key.Decrements the size (assuming the item was actually in the map). - Specified by:
- removein interface- Map<Key,- Value> 
- Parameters:
- key- the item's key
- Returns:
- the item
- Throws:
- NoSuchElementException- if- keyis not contained
 
- 
itemsDescription copied from interface:ContainerGet an iterable that yields each item once.
 
-