Public Member Functions | Private Attributes
mbl_stl_index_functor< T > Class Template Reference

Given a vector of things, select an indexed element. More...

#include <mbl_stl.h>

List of all members.

Public Member Functions

 mbl_stl_index_functor (const vcl_vector< T > &vec)
const T & operator() (unsigned index) const

Private Attributes

const vcl_vector< T > & vec_
 const reference to vector used to store the objects indexed.

Detailed Description

template<class T>
class mbl_stl_index_functor< T >

Given a vector of things, select an indexed element.

For use in eg STL transform algorithm to extract out required subset of (indexed) objects into a working vector e.g. given vector of indices and vector of values, copy out the required subset thus

 vcl_vector<T> subset
 subset.reserve(indices.size());
 vcl_transform(indices.begin(),indices.end(),
               vcl_back_inserter(subset),
               mbl_stl_index_functor(values));

Definition at line 153 of file mbl_stl.h.


Constructor & Destructor Documentation

template<class T >
mbl_stl_index_functor< T >::mbl_stl_index_functor ( const vcl_vector< T > &  vec) [inline]

Definition at line 163 of file mbl_stl.h.


Member Function Documentation

template<class T >
const T& mbl_stl_index_functor< T >::operator() ( unsigned  index) const [inline]

Definition at line 164 of file mbl_stl.h.


Member Data Documentation

template<class T >
const vcl_vector<T >& mbl_stl_index_functor< T >::vec_ [private]

const reference to vector used to store the objects indexed.

Definition at line 160 of file mbl_stl.h.


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