Package com.zybooks.dsaj.map
Interface SortedMap<K,V>
- Type Parameters:
K
- The key type (keys must be unique and comparable)V
- The value type
- All Superinterfaces:
Map<K,
V>
- All Known Implementing Classes:
AbstractSortedMap
,AVLTreeMap
,RBTreeMap
,SortedTableMap
,SplayTreeMap
,TreeMap
A map with additional support for keys from a total ordering.
The total ordering is the natural ordering of keys, by default,
or it can be defined by providing an optional Comparator.
All iterations will be in sorted order relative to the keys,
and additional methods provide for non-exact searches.
This interface is a simple variant that blends features of
java.util.SortedMap and java.util.NavigableMap.
-
Method Summary
Modifier and TypeMethodDescriptionceilingEntry
(K key) Returns the entry with least key greater than or equal to given key (or null if no such key exists).Returns the entry having the least key (or null if map is empty).floorEntry
(K key) Returns the entry with greatest key less than or equal to given key (or null if no such key exists).higherEntry
(K key) Returns the entry with least key strictly greater than given key (or null if no such key exists).Returns the entry having the greatest key (or null if map is empty).lowerEntry
(K key) Returns the entry with greatest key strictly less than given key (or null if no such key exists).Returns an iterable containing all keys in the range fromfromKey
inclusive totoKey
exclusive.
-
Method Details
-
firstEntry
Returns the entry having the least key (or null if map is empty).- Returns:
- entry with least key (or null if map is empty)
-
lastEntry
Returns the entry having the greatest key (or null if map is empty).- Returns:
- entry with greatest key (or null if map is empty)
-
ceilingEntry
Returns the entry with least key greater than or equal to given key (or null if no such key exists).- Parameters:
key
- the target key- Returns:
- entry with least key greater than or equal to given (or null if no such entry)
- Throws:
IllegalArgumentException
- if the key is not compatible with the map
-
floorEntry
Returns the entry with greatest key less than or equal to given key (or null if no such key exists).- Parameters:
key
- the target key- Returns:
- entry with greatest key less than or equal to given (or null if no such entry)
- Throws:
IllegalArgumentException
- if the key is not compatible with the map
-
lowerEntry
Returns the entry with greatest key strictly less than given key (or null if no such key exists).- Parameters:
key
- the target key- Returns:
- entry with greatest key strictly less than given (or null if no such entry)
- Throws:
IllegalArgumentException
- if the key is not compatible with the map
-
higherEntry
Returns the entry with least key strictly greater than given key (or null if no such key exists).- Parameters:
key
- the target key- Returns:
- entry with least key strictly greater than given (or null if no such entry)
- Throws:
IllegalArgumentException
- if the key is not compatible with the map
-
subMap
Returns an iterable containing all keys in the range fromfromKey
inclusive totoKey
exclusive.- Parameters:
fromKey
- the lowest key allowed in the desired rangetoKey
- the highest key allowed in the desired range- Returns:
- iterable with keys in desired range
- Throws:
IllegalArgumentException
- iffromKey
ortoKey
is not compatible with the map
-