mxnet
Public Member Functions | List of all members
dmlc::array_view< ValueType > Class Template Reference

Read only data structure to reference continuous memory region of array. Provide unified view for vector, array and C style array. This data structure do not guarantee aliveness of referenced array. More...

#include <array_view.h>

Collaboration diagram for dmlc::array_view< ValueType >:
Collaboration graph

Public Member Functions

 array_view ()=default
 default constructor More...
 
 array_view (const array_view< ValueType > &other)=default
 default copy constructor More...
 
 array_view (array_view< ValueType > &&other)=default
 default move constructor More...
 
array_view< ValueType > & operator= (const array_view< ValueType > &other)=default
 default assign constructor More...
 
 array_view (const std::vector< ValueType > &other)
 construct array view std::vector More...
 
template<std::size_t size>
 array_view (const std::array< ValueType, size > &other)
 construct array std::array More...
 
 array_view (const ValueType *begin, const ValueType *end)
 construct array view from continuous segment More...
 
size_t size () const
 
const ValueType * begin () const
 
const ValueType * end () const
 
const ValueType & operator[] (size_t i) const
 get i-th element from the view More...
 

Detailed Description

template<typename ValueType>
class dmlc::array_view< ValueType >

Read only data structure to reference continuous memory region of array. Provide unified view for vector, array and C style array. This data structure do not guarantee aliveness of referenced array.

Make sure do not use array_view to record data in async function closures. Also do not use array_view to create reference to temporary data structure.

Template Parameters
ValueTypeThe value
std::vector<int> myvec{1,2,3};
// indexed visit to the view.
LOG(INFO) << view[0];
for (int v : view) {
// visit each element in the view
}

Constructor & Destructor Documentation

template<typename ValueType>
dmlc::array_view< ValueType >::array_view ( )
default

default constructor

template<typename ValueType>
dmlc::array_view< ValueType >::array_view ( const array_view< ValueType > &  other)
default

default copy constructor

Parameters
otheranother array view.
template<typename ValueType>
dmlc::array_view< ValueType >::array_view ( array_view< ValueType > &&  other)
default

default move constructor

Parameters
otheranother array view.
template<typename ValueType>
dmlc::array_view< ValueType >::array_view ( const std::vector< ValueType > &  other)
inline

construct array view std::vector

Parameters
othervector container
template<typename ValueType>
template<std::size_t size>
dmlc::array_view< ValueType >::array_view ( const std::array< ValueType, size > &  other)
inline

construct array std::array

Parameters
otheranother array view.
template<typename ValueType>
dmlc::array_view< ValueType >::array_view ( const ValueType *  begin,
const ValueType *  end 
)
inline

construct array view from continuous segment

Parameters
beginbeginning pointre
endend pointer

Member Function Documentation

template<typename ValueType>
const ValueType* dmlc::array_view< ValueType >::begin ( ) const
inline
Returns
begin of the array
template<typename ValueType>
const ValueType* dmlc::array_view< ValueType >::end ( ) const
inline
Returns
end point of the array
template<typename ValueType>
array_view<ValueType>& dmlc::array_view< ValueType >::operator= ( const array_view< ValueType > &  other)
default

default assign constructor

Parameters
otheranother array view.
Returns
self.
template<typename ValueType>
const ValueType& dmlc::array_view< ValueType >::operator[] ( size_t  i) const
inline

get i-th element from the view

Parameters
iThe index.
Returns
const reference to i-th element.
template<typename ValueType>
size_t dmlc::array_view< ValueType >::size ( ) const
inline
Returns
size of the array

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