shadow:utility

Interface OrderedMap<K,V>

Interfaces

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.

See Also

Method Summary

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.

Method Detail

ceiling

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.

Parameters

key - key to find the ceiling of

Returns

ceiling of given key, or null if no such key exists

floor

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.

Parameters

key - key to find the floor of

Returns

floor of given key, or null if no such key exists

keys

public readonly keys() => (CanIterate<K>)

Method should return an iterable collection of all the keys in the ordered map.

Returns

iterable collection of all keys

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.

Parameters

low - lowest possible key in the range

high - highest possible key in the range

Returns

iterable collection of keys in the range

max

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.

Returns

highest key

min

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.

Returns

lowest key