Map#

class Map(_Map__tree: Option[MapTreeLeaf[Key, Value]] | None = None)#

The immutable map class.

for_all(predicate: Callable[[Key, Value], bool]) bool#

Test all elements in map.

Returns true if the given predicate returns true for all of the bindings in the map.

Parameters:

predicate – The function to test the input elements.

Returns:

True if the predicate evaluates to true for all of the bindings in the map.

items() a set-like object providing a view on D's items#
map(mapping: Callable[[Key, Value], Result]) Map[Key, Result]#

Map the mapping.

Builds a new collection whose elements are the results of applying the given function to each of the elements of the collection. The key passed to the function indicates the key of element being transformed.

Parameters:

mapping – The function to transform the key/value pairs

Returns:

The resulting map of keys and transformed values.

static of_block(lst: Block[tuple[Key, Value]]) Map[Key, Value]#

Generate map from list.

Returns:

The new map.

static of_list(lst: list[tuple[Key, Value]]) Map[Key, Value]#

Generate map from list.

Returns:

The new map.

static of_seq(sequence: Iterable[tuple[Key, Value]]) Map[Key, Value]#

Generate map from sequence.

Generates a new map from an iterable of key/value tuples. This is an alias for Map.create.

Returns:

The new map.

to_seq() Iterable[tuple[Key, Value]]#

Convert to sequence.

Returns:

Sequence of key, value tuples.

count(table: Map[Any, Any]) int#

Return the number of bindings in the map.

is_empty(table: Map[Any, Any]) bool#

Is the map empty?

Parameters:

table – The input map.

Returns:

True if the map is empty.

of(**args: Value) Map[str, Value]#

Create map from arguments.