class type_param_demo.Map[K, V][source]

Maps keys of type K to values of type V.

Type Parameters:
K

Key type.

V

Mapped value type.

Constructors

Map()[source]
Map(items: Mapping[K, V])
Map(items: Iterable[tuple[K, V]])

Construct from the specified items.

Public members

clear()[source]

Clear the map.

keys() -> KeysView[K][source]

Return a dynamic view of the keys.

items() -> ItemsView[K, V][source]

Return a dynamic view of the items.

values() -> ValuesView[V][source]

Return a dynamic view of the values.

get(key: K) -> V | None[source]
get(key: K, default: V) -> V
get[T](key: K, default: T) -> V | T

Return the mapped value, or the specified default.

__len__() -> int[source]

Return the number of items in the map.

__contains__(key: K) -> bool[source]

Check if the map contains key.

__getitem__(key: K) -> V[source]

Return the value associated with key.

__setitem__(key: K, value: V)[source]

Set the value associated with the specified key.

__delitem__(key: K)[source]

Remove the value associated with the specified key.

__iter__() -> Iterator[K][source]

Iterate over the keys.