Mojo struct
DictEntry
struct DictEntry[K: Copyable & Movable & Hashable & EqualityComparable, V: Copyable & Movable, H: Hasher]
Store a key-value pair entry inside a dictionary.
Parameters
- K (
Copyable&Movable&Hashable&EqualityComparable): The key type of the dict. Must be Hashable+EqualityComparable. - V (
Copyable&Movable): The value type of the dict. - H (
Hasher): The type of the hasher used to hash the key.
Fields
- hash (
UInt64):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,
Movable,
UnknownDestructibility
Aliases
__copyinit__is_trivial
alias __copyinit__is_trivial = V.__copyinit__is_trivial if K.__copyinit__is_trivial if UInt64.__copyinit__is_trivial else UInt64.__copyinit__is_trivial else K.__copyinit__is_trivial if UInt64.__copyinit__is_trivial else UInt64.__copyinit__is_trivial
__del__is_trivial
alias __del__is_trivial = V.__del__is_trivial if K.__del__is_trivial if UInt64.__del__is_trivial else UInt64.__del__is_trivial else K.__del__is_trivial if UInt64.__del__is_trivial else UInt64.__del__is_trivial
__moveinit__is_trivial
alias __moveinit__is_trivial = V.__moveinit__is_trivial if K.__moveinit__is_trivial if UInt64.__moveinit__is_trivial else UInt64.__moveinit__is_trivial else K.__moveinit__is_trivial if UInt64.__moveinit__is_trivial else UInt64.__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.
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!