Class MapObj#

Inheritance Relationships#

Base Type#

Derived Types#

Class Documentation#

class MapObj : public tvm::ffi::Object#

Shared content of all specializations of hash map.

Subclassed by tvm::ffi::DenseMapObj, tvm::ffi::SmallMapObj

Public Types

using key_type = Any#

Type of the keys in the hash map.

using mapped_type = Any#

Type of the values in the hash map.

using KVType = std::pair<Any, Any>#

Type of value stored in the hash map.

Public Functions

inline size_t size() const#

Number of elements in the MapObj.

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

Public Static Functions

static inline ObjectPtr<MapObj> Empty()#

Create an empty container.

Returns:

The object created

Protected Functions

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

void (*data_deleter_)(void*) = nullptr#

Optional data deleter when data is allocated separately and its deletion is not managed by MapObj::deleter_.

Protected Static Functions

template<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:

IterType – The type of iterator

Returns:

ObjectPtr to the map created

static inline void InsertMaybeReHash(KVType &&kv, ObjectPtr<Object> *map)#

InsertMaybeReHash an entry into the given hash map.

Parameters:
  • kv – The entry to be inserted

  • map – The pointer to the map, can be changed if re-hashing happens

static inline ObjectPtr<MapObj> CopyFrom(MapObj *from)#

Create an empty container with elements copying from another SmallMapObj.

Parameters:

from – The source container

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 Map