shark::DataView< DatasetType > Class Template Reference

Constant time Element-Lookup for Datasets. More...

#include <shark/Data/DataView.h>

Public Types

typedef dataset_type::const_element_reference const_reference
 
typedef boost::mpl::if_< boost::is_const< DatasetType >, typename dataset_type::const_element_reference, typename dataset_type::element_reference >::type reference
 
typedef IteratorBase< reference, DataView< DatasetType > > iterator
 
typedef IteratorBase< const_reference, DataView< DatasetType > const > const_iterator
 

Public Member Functions

 DataView ()
 
 DataView (DatasetType &dataset)
 
template<class IndexRange >
 DataView (DataView< DatasetType > const &view, IndexRange const &indices)
 create a subset of the dataset type using only the elemnt indexed by indices More...
 
reference operator[] (std::size_t position)
 
const_reference operator[] (std::size_t position) const
 
std::size_t index (std::size_t position) const
 returns the position of the element inside the dataset More...
 
std::size_t size () const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
dataset_type const & dataset () const
 

Detailed Description

template<class DatasetType>
class shark::DataView< DatasetType >

Constant time Element-Lookup for Datasets.

Datasets are fast for random lookup of batches. Since batch sizes can be arbitrary structured and changed by the user, there is no way for the Data and LabeledData classes to provide fast random access to single elements. Still, this property is needed quite often, for example for creating subsets, randomize data or tree structures. A View stores the position of every element in a dataset. So it has constant time access to the elements but it also requires linear memory in the number of elements in the set. This is typically small compared to the size of the set itself, but construction imposes an considerable overhead.

In contrast to (Un)LabeledData, which is centered around batches, the View is centered around single elements, so its iterators iterate over the elements. For a better support for bagging an index method is added which returns the position of the element in the underlying data container. Also the iterators are indexed and return this index.

Definition at line 63 of file DataView.h.

Member Typedef Documentation

§ const_iterator

template<class DatasetType>
typedef IteratorBase<const_reference, DataView<DatasetType> const > shark::DataView< DatasetType >::const_iterator

Definition at line 141 of file DataView.h.

§ const_reference

template<class DatasetType>
typedef dataset_type::const_element_reference shark::DataView< DatasetType >::const_reference

Definition at line 68 of file DataView.h.

§ iterator

template<class DatasetType>
typedef IteratorBase<reference,DataView<DatasetType> > shark::DataView< DatasetType >::iterator

Definition at line 140 of file DataView.h.

§ reference

template<class DatasetType>
typedef boost::mpl::if_< boost::is_const<DatasetType>, typename dataset_type::const_element_reference, typename dataset_type::element_reference >::type shark::DataView< DatasetType >::reference

Definition at line 76 of file DataView.h.

Constructor & Destructor Documentation

§ DataView() [1/3]

template<class DatasetType>
shark::DataView< DatasetType >::DataView ( )
inline

Definition at line 143 of file DataView.h.

§ DataView() [2/3]

template<class DatasetType>
shark::DataView< DatasetType >::DataView ( DatasetType &  dataset)
inline

Definition at line 144 of file DataView.h.

§ DataView() [3/3]

template<class DatasetType>
template<class IndexRange >
shark::DataView< DatasetType >::DataView ( DataView< DatasetType > const &  view,
IndexRange const &  indices 
)
inline

create a subset of the dataset type using only the elemnt indexed by indices

Definition at line 160 of file DataView.h.

Member Function Documentation

§ begin() [1/2]

template<class DatasetType>
iterator shark::DataView< DatasetType >::begin ( )
inline

Definition at line 189 of file DataView.h.

§ begin() [2/2]

template<class DatasetType>
const_iterator shark::DataView< DatasetType >::begin ( ) const
inline

Definition at line 192 of file DataView.h.

§ dataset()

template<class DatasetType>
dataset_type const& shark::DataView< DatasetType >::dataset ( ) const
inline

§ end() [1/2]

template<class DatasetType>
iterator shark::DataView< DatasetType >::end ( )
inline

Definition at line 195 of file DataView.h.

§ end() [2/2]

template<class DatasetType>
const_iterator shark::DataView< DatasetType >::end ( ) const
inline

Definition at line 198 of file DataView.h.

§ index()

template<class DatasetType>
std::size_t shark::DataView< DatasetType >::index ( std::size_t  position) const
inline

returns the position of the element inside the dataset

This is useful for bagging, when identical elements among several subsets are to be identified.

Definition at line 181 of file DataView.h.

Referenced by shark::DataView< shark::Data< LabelType > const >::DataView(), and shark::DataView< shark::Data< LabelType > const >::operator[]().

§ operator[]() [1/2]

template<class DatasetType>
reference shark::DataView< DatasetType >::operator[] ( std::size_t  position)
inline

Definition at line 167 of file DataView.h.

§ operator[]() [2/2]

template<class DatasetType>
const_reference shark::DataView< DatasetType >::operator[] ( std::size_t  position) const
inline

Definition at line 172 of file DataView.h.

§ size()


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