mxnet
Classes | Public Types | Public Member Functions | List of all members
mxnet::runtime::Map< K, V, typename, typename > Class Template Reference

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. More...

#include <container_ext.h>

Inheritance diagram for mxnet::runtime::Map< K, V, typename, typename >:
Inheritance graph
Collaboration diagram for mxnet::runtime::Map< K, V, typename, typename >:
Collaboration graph

Classes

class  iterator
 Iterator of the hash map. More...
 

Public Types

using key_type = K
 
using mapped_type = V
 
using ContainerType = MapObj
 specify container node More...
 
- Public Types inherited from mxnet::runtime::ObjectRef
using ContainerType = Object
 type indicate the container type. More...
 

Public Member Functions

 Map ()
 default constructor More...
 
 Map (Map< K, V > &&other)
 move constructor More...
 
 Map (const Map< K, V > &other)
 copy constructor More...
 
Map< K, V > & operator= (Map< K, V > &&other)
 copy assign operator More...
 
Map< K, V > & operator= (const Map< K, V > &other)
 move assign operator More...
 
 Map (ObjectPtr< Object > n)
 constructor from pointer More...
 
template<typename IterType >
 Map (IterType begin, IterType end)
 constructor from iterator More...
 
 Map (std::initializer_list< std::pair< K, V >> init)
 constructor from initializer list More...
 
template<typename Hash , typename Equal >
 Map (const std::unordered_map< K, V, Hash, Equal > &init)
 constructor from unordered_map More...
 
const V at (const K &key) const
 Read element from map. More...
 
const V operator[] (const K &key) const
 Read element from map. More...
 
size_t size () const
 
size_t count (const K &key) const
 
bool empty () const
 
void Set (const K &key, const V &value)
 set the Map. More...
 
iterator begin () const
 
iterator end () const
 
iterator find (const K &key) const
 
void erase (const K &key)
 
MapObjCopyOnWrite ()
 copy on write semantics Do nothing if current handle is the unique copy of the array. Otherwise make a new copy of the array to ensure the current handle hold a unique copy. More...
 
- Public Member Functions inherited from mxnet::runtime::ObjectRef
 ObjectRef ()=default
 default constructor More...
 
 ObjectRef (ObjectPtr< Object > data)
 Constructor from existing object ptr. More...
 
bool same_as (const ObjectRef &other) const
 Comparator. More...
 
bool operator== (const ObjectRef &other) const
 Comparator. More...
 
bool operator!= (const ObjectRef &other) const
 Comparator. More...
 
bool operator< (const ObjectRef &other) const
 Comparator. More...
 
bool defined () const
 
const Objectget () const
 
const Objectoperator-> () const
 
bool unique () const
 
template<typename ObjectType >
const ObjectType * as () const
 Try to downcast the internal Object to a raw pointer of a corresponding type. More...
 

Additional Inherited Members

- Static Public Attributes inherited from mxnet::runtime::ObjectRef
static constexpr bool _type_is_nullable = true
 
- Protected Member Functions inherited from mxnet::runtime::ObjectRef
Objectget_mutable () const
 
- Static Protected Member Functions inherited from mxnet::runtime::ObjectRef
template<typename T >
static T DowncastNoCheck (ObjectRef ref)
 Internal helper function downcast a ref without check. More...
 
template<typename ObjectType >
static ObjectPtr< ObjectType > GetDataPtr (const ObjectRef &ref)
 Internal helper function get data_ as ObjectPtr of ObjectType. More...
 
- Protected Attributes inherited from mxnet::runtime::ObjectRef
ObjectPtr< Objectdata_
 Internal pointer that backs the reference. More...
 

Detailed Description

template<typename K, typename V, typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
class mxnet::runtime::Map< K, V, typename, typename >

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
KThe key NodeRef type.
VThe value NodeRef type.

Member Typedef Documentation

◆ ContainerType

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
using mxnet::runtime::Map< K, V, typename, typename >::ContainerType = MapObj

specify container node

◆ key_type

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
using mxnet::runtime::Map< K, V, typename, typename >::key_type = K

◆ mapped_type

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
using mxnet::runtime::Map< K, V, typename, typename >::mapped_type = V

Constructor & Destructor Documentation

◆ Map() [1/7]

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
mxnet::runtime::Map< K, V, typename, typename >::Map ( )
inline

default constructor

◆ Map() [2/7]

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
mxnet::runtime::Map< K, V, typename, typename >::Map ( Map< K, V > &&  other)
inline

move constructor

Parameters
othersource

◆ Map() [3/7]

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
mxnet::runtime::Map< K, V, typename, typename >::Map ( const Map< K, V > &  other)
inline

copy constructor

Parameters
othersource

◆ Map() [4/7]

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
mxnet::runtime::Map< K, V, typename, typename >::Map ( ObjectPtr< Object n)
inlineexplicit

constructor from pointer

Parameters
nthe container pointer

◆ Map() [5/7]

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
template<typename IterType >
mxnet::runtime::Map< K, V, typename, typename >::Map ( IterType  begin,
IterType  end 
)
inline

constructor from iterator

Parameters
beginbegin of iterator
endend of iterator
Template Parameters
IterTypeThe type of iterator

◆ Map() [6/7]

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
mxnet::runtime::Map< K, V, typename, typename >::Map ( std::initializer_list< std::pair< K, V >>  init)
inline

constructor from initializer list

Parameters
initThe initalizer list

◆ Map() [7/7]

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
template<typename Hash , typename Equal >
mxnet::runtime::Map< K, V, typename, typename >::Map ( const std::unordered_map< K, V, Hash, Equal > &  init)
inline

constructor from unordered_map

Parameters
initThe unordered_map

Member Function Documentation

◆ at()

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
const V mxnet::runtime::Map< K, V, typename, typename >::at ( const K &  key) const
inline

Read element from map.

Parameters
keyThe key
Returns
the corresonding element.

◆ begin()

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
iterator mxnet::runtime::Map< K, V, typename, typename >::begin ( ) const
inline
Returns
begin iterator

◆ CopyOnWrite()

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
MapObj* mxnet::runtime::Map< K, V, typename, typename >::CopyOnWrite ( )
inline

copy on write semantics Do nothing if current handle is the unique copy of the array. Otherwise make a new copy of the array to ensure the current handle hold a unique copy.

Returns
Handle to the internal node container(which ganrantees to be unique)

◆ count()

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
size_t mxnet::runtime::Map< K, V, typename, typename >::count ( const K &  key) const
inline
Returns
The number of elements of the key

◆ empty()

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
bool mxnet::runtime::Map< K, V, typename, typename >::empty ( ) const
inline
Returns
whether array is empty

◆ end()

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
iterator mxnet::runtime::Map< K, V, typename, typename >::end ( ) const
inline
Returns
end iterator

◆ erase()

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
void mxnet::runtime::Map< K, V, typename, typename >::erase ( const K &  key)
inline

◆ find()

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
iterator mxnet::runtime::Map< K, V, typename, typename >::find ( const K &  key) const
inline
Returns
find the key and returns the associated iterator

◆ operator=() [1/2]

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
Map<K, V>& mxnet::runtime::Map< K, V, typename, typename >::operator= ( const Map< K, V > &  other)
inline

move assign operator

Parameters
otherThe source of assignment
Returns
reference to self.

◆ operator=() [2/2]

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
Map<K, V>& mxnet::runtime::Map< K, V, typename, typename >::operator= ( Map< K, V > &&  other)
inline

copy assign operator

Parameters
otherThe source of assignment
Returns
reference to self.

◆ operator[]()

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
const V mxnet::runtime::Map< K, V, typename, typename >::operator[] ( const K &  key) const
inline

Read element from map.

Parameters
keyThe key
Returns
the corresonding element.

◆ Set()

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
void mxnet::runtime::Map< K, V, typename, typename >::Set ( const K &  key,
const V &  value 
)
inline

set the Map.

Parameters
keyThe index key.
valueThe value to be setted.

◆ size()

template<typename K , typename V , typename = typename std::enable_if<std::is_base_of<ObjectRef, K>::value>::type, typename = typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
size_t mxnet::runtime::Map< K, V, typename, typename >::size ( ) const
inline
Returns
The size of the array

The documentation for this class was generated from the following file: