Template Class Dict#
Defined in File dict.h
Inheritance Relationships#
Base Type#
public tvm::ffi::ObjectRef(Class ObjectRef)
Class Documentation#
-
template<typename K, typename V, typename = typename std::enable_if_t<details::storage_enabled_v<K> && details::storage_enabled_v<V>>>
class Dict : public tvm::ffi::ObjectRef# Mutable dictionary container with shared reference semantics.
Mutations happen directly on the underlying shared DictObj. All handles sharing the same DictObj see mutations immediately.
- Template Parameters:
K – The key type.
V – The value type.
Public Types
Public Functions
-
inline explicit Dict(UnsafeInit tag)#
Construct a Dict with UnsafeInit.
-
inline Dict()#
default constructor
-
template<typename KU, typename VU, typename = std::enable_if_t<details::type_contains_v<K, KU> && details::type_contains_v<V, VU>>>
inline Dict(Dict<KU, VU> &&other)# Move constructor.
- Parameters:
other – The other dict
- Template Parameters:
KU – The key type of the other dict
VU – The mapped type of the other dict
-
template<typename KU, typename VU, typename = std::enable_if_t<details::type_contains_v<K, KU> && details::type_contains_v<V, VU>>>
inline Dict(const Dict<KU, VU> &other)# Copy constructor.
- Parameters:
other – The other dict
- Template Parameters:
KU – The key type of the other dict
VU – The mapped type of the other dict
-
inline explicit Dict(ObjectPtr<Object> n)#
constructor from pointer
- Parameters:
n – the container pointer
-
template<typename IterType>
inline Dict(IterType begin, IterType end)# constructor from iterator
- Parameters:
begin – begin of iterator
end – end of iterator
- Template Parameters:
IterType – The type of iterator
-
inline Dict(std::initializer_list<std::pair<K, V>> init)#
constructor from initializer list
- Parameters:
init – The initalizer list
-
template<typename Hash, typename Equal>
inline Dict(const std::unordered_map<K, V, Hash, Equal> &init)# constructor from unordered_map
- Parameters:
init – The unordered_map
-
inline V at(const K &key) const#
Read element from dict.
- Parameters:
key – The key
- Returns:
the corresponding element.
-
inline size_t size() const#
- Returns:
The size of the dict
-
inline bool empty() const#
- Returns:
whether dict is empty
-
inline void clear()#
Release reference to all the elements.
-
inline void Set(const K &key, const V &value)#
Set a key-value pair in the Dict (mutates in-place).
- Parameters:
key – The index key.
value – The value to be set.
-
inline iterator begin() const#
- Returns:
begin iterator
-
inline iterator end() const#
- Returns:
end iterator