Template Class Map#
Defined in File map.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 Map : public tvm::ffi::ObjectRef# Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics, which means map is mutable but copy will happen when array is referenced in more than two places.
operator[] only provide const acces, use Set to mutate the content.
- Template Parameters:
K – The key NodeRef type.
V – The value NodeRef type.
Public Types
Public Functions
-
inline explicit Map(UnsafeInit tag)#
Construct an Map with UnsafeInit.
-
inline Map()#
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 Map(Map<KU, VU> &&other)# Move constructor.
- Parameters:
other – The other map
- Template Parameters:
KU – The key type of the other map
VU – The mapped type of the other map
-
template<typename KU, typename VU, typename = std::enable_if_t<details::type_contains_v<K, KU> && details::type_contains_v<V, VU>>>
inline Map(const Map<KU, VU> &other)# Copy constructor.
- Parameters:
other – The other map
- Template Parameters:
KU – The key type of the other map
VU – The mapped type of the other map
-
inline explicit Map(ObjectPtr<Object> n)#
constructor from pointer
- Parameters:
n – the container pointer
-
template<typename IterType>
inline Map(IterType begin, IterType end)# constructor from iterator
- Parameters:
begin – begin of iterator
end – end of iterator
- Template Parameters:
IterType – The type of iterator
-
inline Map(std::initializer_list<std::pair<K, V>> init)#
constructor from initializer list
- Parameters:
init – The initalizer list
-
template<typename Hash, typename Equal>
inline Map(const std::unordered_map<K, V, Hash, Equal> &init)# constructor from unordered_map
- Parameters:
init – The unordered_map
-
inline const V at(const K &key) const#
Read element from map.
- Parameters:
key – The key
- Returns:
the corresonding element.
-
inline size_t size() const#
- Returns:
The size of the array
-
inline bool empty() const#
- Returns:
whether array is empty
-
inline void clear()#
Release reference to all the elements.
-
inline void Set(const K &key, const V &value)#
set the Map.
- Parameters:
key – The index key.
value – The value to be setted.
-
inline iterator begin() const#
- Returns:
begin iterator
-
inline iterator end() const#
- Returns:
end iterator