shadow:utility@Map<K,V>
interface OrderedMap<K is CanCompare<K>, V is CanEqual<V>>
Interface OrderedMap<K,V>
defines the operations that a class must implement to be an ordered map, also known as an ordered symbol table. An ordered map is used to store key-value pairs with key type K
and value type V
. It should be possible to find keys quickly, allowing for efficient insertion and retrieval of associated values. OrderedMap<K,V>
differs from Map<K,V>
in that key values must have some ordering defined by the CanCompare<K>
interface. Because of this ordering, OrderedMap<K,V>
is also able to define methods that manipulate ranges of key values.
Modifiers | Return Types | Method and Description |
---|---|---|
public readonly |
(nullable K) |
ceiling(K key) Method should return the lowest-valued key whose value is greater than or equal to the given key. |
public readonly |
(nullable K) |
floor(K key) Method should return the highest-valued key whose value is less than or equal to the given key. |
public readonly |
(CanIterate<K>) |
keys() Method should return an iterable collection of all the keys in the ordered map. |
public readonly |
(CanIterate<K>) |
keys(K low, K high) Method should return an iterable collection of all the keys in the ordered map whose values are in the inclusive range from the low key to the high key given. |
public readonly |
(K) |
max() Method should return the highest-valued key in the ordered map or throw an exception if the ordered map is empty. |
public readonly |
(K) |
min() Method should return the lowest-valued key in the ordered map or throw an exception if the ordered map is empty. |
public readonly ceiling(K key) => (nullable K)
Method should return the lowest-valued key whose value is greater than or equal to the given key.
key
- key to find the ceiling of
ceiling of given key, or null
if no such key exists
public readonly floor(K key) => (nullable K)
Method should return the highest-valued key whose value is less than or equal to the given key.
key
- key to find the floor of
floor of given key, or null
if no such key exists
public readonly keys() => (CanIterate<K>)
Method should return an iterable collection of all the keys in the ordered map.
iterable collection of all keys
public readonly keys(K low, K high) => (CanIterate<K>)
Method should return an iterable collection of all the keys in the ordered map whose values are in the inclusive range from the low key to the high key given.
low
- lowest possible key in the range
high
- highest possible key in the range
iterable collection of keys in the range
public readonly max() => (K)
Method should return the highest-valued key in the ordered map or throw an exception if the ordered map is empty.
highest key
public readonly min() => (K)
Method should return the lowest-valued key in the ordered map or throw an exception if the ordered map is empty.
lowest key