shadow:utility

Interface Map<K,V>

Interfaces

shadow:standard@CanIterate<V>, shadow:standard@CanIndexNullable<K,V>, shadow:standard@CanIndexStore<K,V>

interface Map<K is CanEqual<K>, V is CanEqual<V>>

Interface Map<K,V> defines the operations that a class must implement to be a map, also known as a symbol table. A 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. Map<K,V> differs from OrderedMap<K,V> in that an ordering of key values is not required.

See Also

Method Summary

Modifiers Return Types Method and Description
public (Map<K,V>) clear()

Removes all key-value pairs from the map.

public readonly (boolean) containsKey(K key)

Method should check whether the map contains a matching key.

public readonly (boolean) containsValue(V value)

Method should check whether the map contains a matching value.

public readonly (boolean) isEmpty()

Method should check whether or not the map is empty.

public (nullable V) remove(K key)

Method should remove the given key and its associated value.

Property Summary

Modifiers Return Types Method and Description
public readonly get (int) size()

Property should get the number of key-value pairs stored in the map as an int.

public readonly get (long) sizeLong()

Property should get the number of key-value pairs stored in the map as a long.

Method Detail

clear

public clear() => (Map<K,V>)

Removes all key-value pairs from the map. This operation should run in constant time.

Returns

map after being cleared

containsKey

public readonly containsKey(K key) => (boolean)

Method should check whether the map contains a matching key. Since maps are usually organized by values, this operation should be efficient, running in either constant or logarithmic time, depending on the implementation.

Parameters

key - key to search for

Returns

true if key is found

containsValue

public readonly containsValue(V value) => (boolean)

Method should check whether the map contains a matching value. Note that maps are not usually organized by values, so this operation may require a linear search of the entire map.

Parameters

value - value to search for

Returns

true if value is found

isEmpty

public readonly isEmpty() => (boolean)

Method should check whether or not the map is empty.

Returns

true if the map is empty

remove

public remove(K key) => (nullable V)

Method should remove the given key and its associated value.

Parameters

key - key to search for

Returns

associated value if key is present, null otherwise

Property Detail

size

public readonly get size() => (int)

Property should get the number of key-value pairs stored in the map as an int.

Returns

size of the map

sizeLong

public readonly get sizeLong() => (long)

Property should get the number of key-value pairs stored in the map as a long.

Returns

size of the list