Package dsa.lab04.base
Interface Map<Key,Value> 
- Type Parameters:
- Key- the key type
- Value- the value type
- All Known Subinterfaces:
- OrderedMap<Key,- Value> 
- All Known Implementing Classes:
- ArrayMap,- ArrayMap,- AVLTree,- AVLTree,- BinarySearchTree,- BinarySearchTree,- ChainingHashMap,- ChainingHashMap,- ProbingHashMap,- ProbingHashMap,- SortedArrayMap,- SortedArrayMap
A map.
 
A container where the items have unique keys. An item consists of a key and a value. The key is the uniquely identifying part of the item. The value is everything else.
- 
Method SummaryModifier and TypeMethodDescriptiondefault booleancontainsKey(Key key) Check if the given key is equal to any of those contained.default booleancontainsValue(Value value) Check if the given value is equal to any of those contained.Find the item with the given key.default ValueGet the value associated with the given key.voidInsert the given item.default voidInsert an item with the given key and value.keys()Get an iterable that yields each key once.Remove and return the item with the given key.values()Get an iterable that yields each value once.Methods inherited from interface java.lang.IterableforEach, spliterator
- 
Method Details- 
findFind the item with the given key.- Parameters:
- key- the item's key
- Returns:
- the item
- Throws:
- NoSuchElementException- if no item has key- key
 
- 
insertInsert 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. - Parameters:
- item- the item
 
- 
insertInsert an item with the given key and value.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. - Parameters:
- key- the item's key
- value- the item's value
 
- 
removeRemove and return the item with the given key.Decrements the size (assuming the item was actually in the map). - Parameters:
- key- the item's key
- Returns:
- the item
- Throws:
- NoSuchElementException- if- keyis not contained
 
- 
containsKeyCheck if the given key is equal to any of those contained.- Parameters:
- key- the key to check for membership
- Returns:
- whether such a key is contained
 
- 
containsValueCheck if the given value is equal to any of those contained.- Parameters:
- value- the value to check for membership
- Returns:
- whether such a value is contained
 
- 
getGet the value associated with the given key.- Parameters:
- key- the key
- Returns:
- the corresponding value
- Throws:
- NoSuchElementException- if- keyis not contained
 
- 
keysGet an iterable that yields each key once.- Returns:
- an iterable over the keys
 
- 
valuesGet an iterable that yields each value once.- Returns:
- an iterable over the values
 
 
-