Package dsa.lab05.base
Interface OrderedMap<Key extends Comparable<Key>,Value>
- Type Parameters:
Key
- the key typeValue
- the value type
- All Known Implementing Classes:
AVLTree
,AVLTree
,BinarySearchTree
,BinarySearchTree
,SortedArrayMap
,SortedArrayMap
An ordered map.
A map whose n
items have comparable keys,
that is, have keys that can be ordered from least to greatest.
-
Method Summary
Modifier and TypeMethodDescriptionitems()
Get a forward iterable that yields each item once.keys()
Get a forward iterable that yields each key once.max()
Get the item with the greatest key.min()
Get the item with the least key.Get the item that would be the successor of one with the given key.Get the item that would be the predecessor of one with the given key.reversed()
Get a reverse iterable that yields each item once.Get a reverse iterable that yields each key once.Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface dsa.lab04.base.Map
containsKey, containsValue, find, get, insert, insert, remove, values
-
Method Details
-
previous
Get the item that would be the predecessor of one with the given key.The map may or may not contain an item with the given key.
- Parameters:
key
- a key- Returns:
- the previous item (by key), or
null
if there is none
-
next
Get the item that would be the successor of one with the given key.The map may or may not contain an item with the given key.
- Parameters:
key
- a key- Returns:
- the next item (by key), or
null
if there is none
-
min
Get the item with the least key.- Returns:
- the minimum item (by key), or
null
if there is none
-
max
Get the item with the greatest key.- Returns:
- the maximum item (by key), or
null
if there is none
-
items
Get a forward iterable that yields each item once.The items are iterated over in least-to-greatest order (by key).
- Specified by:
items
in interfaceContainer<Key extends Comparable<Key>>
- Returns:
- an iterable over the items
-
reversed
Get a reverse iterable that yields each item once.The items are iterated over in greatest-to-least order (by key).
- Returns:
- an iterable over the items
-
keys
Get a forward iterable that yields each key once.The items are iterated over in least-to-greatest order (by key).
-
reversedKeys
Get a reverse iterable that yields each key once.The items are iterated over in greatest-to-least order (by key).
- Returns:
- an iterable over the keys
-