Mojo struct
DictEntry
struct DictEntry[K: KeyElement, V: CollectionElement]
Store a key-value pair entry inside a dictionary.
Parameters
- K (
KeyElement
): The key type of the dict. Must be Hashable+EqualityComparable. - V (
CollectionElement
): The value type of the dict.
Fields
- hash (
Int
):key.__hash__()
, stored so hashing isn't re-computed during dict lookup. - key (
K
): The unique key for the entry. - value (
V
): The value associated with the key.
Implemented traits
AnyType
,
CollectionElement
,
CollectionElementNew
,
Copyable
,
ExplicitlyCopyable
,
Movable
,
UnknownDestructibility
Methods
__init__
__init__(out self, owned key: K, owned value: V)
Create an entry from a key and value, computing the hash.
Args:
- key (
K
): The key of the entry.