Mojo struct
DictEntry
struct DictEntry[K: ExplicitlyCopyable & Movable & Hashable & EqualityComparable, V: ExplicitlyCopyable & Movable, H: Hasher]
Store a key-value pair entry inside a dictionary.
Parameters
- K (
ExplicitlyCopyable
&Movable
&Hashable
&EqualityComparable
): The key type of the dict. Must be Hashable+EqualityComparable. - V (
ExplicitlyCopyable
&Movable
): The value type of the dict. - H (
Hasher
): The type of the hasher used to hash the key.
Fields
- hash (
SIMD[uint64, 1]
):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
,
Copyable
,
ExplicitlyCopyable
,
Movable
,
UnknownDestructibility
Aliases
__copyinit__is_trivial
alias __copyinit__is_trivial = False
__del__is_trivial
alias __del__is_trivial = get_witness(V, stdlib::builtin::anytype::AnyType, __del__is_trivial) if get_witness(K, stdlib::builtin::anytype::AnyType, __del__is_trivial) else get_witness(K, stdlib::builtin::anytype::AnyType, __del__is_trivial)
__moveinit__is_trivial
alias __moveinit__is_trivial = get_witness(V, stdlib::builtin::value::Movable, __moveinit__is_trivial) if get_witness(K, stdlib::builtin::value::Movable, __moveinit__is_trivial) else get_witness(K, stdlib::builtin::value::Movable, __moveinit__is_trivial)
Methods
__init__
__init__(out self, var key: K, var value: V)
Create an entry from a key and value, computing the hash.
Args:
- key (
K
): The key of the entry. - value (
V
): The value of the entry.
__copyinit__
__copyinit__(out self, existing: Self)
Creates a copy of the given entry.
Args:
- existing (
Self
): The entry to copy.
reap_value
reap_value(var self) -> V
Take the value from an owned entry.
Returns:
V
: The value of the entry.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!