Class MapBaseObj#
Defined in File map_base.h
Inheritance Relationships#
Base Type#
public tvm::ffi::Object(Class Object)
Derived Types#
public tvm::ffi::DenseMapBaseObj(Class DenseMapBaseObj)public tvm::ffi::DictObj(Class DictObj)public tvm::ffi::MapObj(Class MapObj)public tvm::ffi::SmallMapBaseObj(Class SmallMapBaseObj)
Class Documentation#
-
class MapBaseObj : public tvm::ffi::Object#
Shared content of all specializations of hash map.
MapBaseObj is transparent to the FFI type system (no type index), following the same pattern as BytesObjBase.
Subclassed by tvm::ffi::DenseMapBaseObj, tvm::ffi::DictObj, tvm::ffi::MapObj, tvm::ffi::SmallMapBaseObj
Public Types
Public Functions
-
inline size_t size() const#
Number of elements in the MapBaseObj.
- Returns:
The result
-
size_t count(const key_type &key) const#
Count the number of times a key exists in the hash map.
- Parameters:
key – The indexing key
- Returns:
The result, 0 or 1
-
const mapped_type &at(const key_type &key) const#
Index value associated with a key, throw exception if the key does not exist.
- Parameters:
key – The indexing key
- Returns:
The const reference to the value
-
mapped_type &at(const key_type &key)#
Index value associated with a key, throw exception if the key does not exist.
- Parameters:
key – The indexing key
- Returns:
The mutable reference to the value
-
iterator begin() const#
- Returns:
begin iterator
-
iterator end() const#
- Returns:
end iterator
-
iterator find(const key_type &key) const#
Index value associated with a key.
- Parameters:
key – The indexing key
- Returns:
The iterator of the entry associated with the key, end iterator if not exists
-
void erase(const iterator &position)#
Erase the entry associated with the iterator.
- Parameters:
position – The iterator
-
inline void erase(const key_type &key)#
Erase the entry associated with the key, do nothing if not exists.
- Parameters:
key – The indexing key
-
void clear()#
clear all entries
Protected Functions
-
inline void InplaceSwitchTo(ObjectPtr<Object> &&other)#
Inplace switch the storage contents to the other map.
The other map will be consumed after this operation The current content will be reset after this operation
- Parameters:
other – The other map
-
inline bool IsSmallMap() const#
Check if the map is a small map.
- Returns:
True if the map is a small map
Protected Attributes
-
void *data_#
data pointer to the data region of the map.
Note
For immutable inplace small map we do not need data_, but we keep it here for future compact with mutable container.
-
uint64_t size_#
number of entries in the container
-
uint64_t slots_#
number of slots
Protected Static Functions
-
template<typename MapObjType>
static inline ObjectPtr<Object> Empty()# Create an empty container.
- Returns:
The object created
-
template<typename MapObjType, typename IterType>
static inline ObjectPtr<Object> CreateFromRange(IterType first, IterType last)# Create the map using contents from the given iterators.
- Parameters:
first – Begin of iterator
last – End of iterator
- Template Parameters:
MapObjType – The type of map object
IterType – The type of iterator
- Returns:
ObjectPtr to the map created
-
template<typename MapObjType>
static inline ObjectPtr<Object> InsertMaybeReHash(KVType &&kv, const ObjectPtr<Object> &map)# InsertMaybeReHash an entry into the given hash map.
- Parameters:
kv – The entry to be inserted
map – The reference to the map container
- Template Parameters:
MapObjType – The type of map object
- Returns:
A new container if re-hashing happens, nullptr otherwise
-
template<typename MapObjType>
static inline ObjectPtr<Object> CopyFrom(MapBaseObj *from)# Create an empty container with elements copying from another SmallMapBaseObj.
- Parameters:
from – The source container
- Template Parameters:
MapObjType – The type of map object
- Returns:
The object created
Protected Static Attributes
-
static constexpr uint64_t kSmallTagMask = static_cast<uint64_t>(1) << 63#
Small layout tag mask.
Note
The most significant bit is used to indicate the small map layout.
Friends
- friend class SmallMapBaseObj
- friend class DenseMapBaseObj
- friend class Dict
-
inline size_t size() const#