template<typename VALUE, typename ITERATOR, typename FILTER>
class tlp::StlFilterIterator< VALUE, ITERATOR, FILTER >
Iterator that enables to filter a Stl Iterator.
- Parameters:
-
startIt | the beginning of the iterator that should be filtered (begin()) |
endIt | the end of the iterator that should be filtered (begin()) |
filter | the functor that enables to test wheter or not an element is filtered |
That example enable to iterate only of elements greater than 50;
class GreaterFilter {
GreaterFilter(double threshold):_t(threshold){
}
bool operator()(double a) {
return a < _t;
}
};
int main() {
vector<double> vec(100);
for (size_t j=0; j<100; ++j)
vec[j] = j;
GreaterFilter filter(50);
double x;
cout << x << endl;
}