Overview     Modules     Class Hierarchy     Classes     Members  
tlp::StlFilterIterator< VALUE, ITERATOR, FILTER > Class Template Reference

Iterator that enables to filter a Stl Iterator. More...

#include <stlfilteriterator.h>

Inheritance diagram for tlp::StlFilterIterator< VALUE, ITERATOR, FILTER >:
Collaboration diagram for tlp::StlFilterIterator< VALUE, ITERATOR, FILTER >:

Public Member Functions

 StlFilterIterator (const ITERATOR &startIt, const ITERATOR &endIt, FILTER filter)
VALUE next ()
 Moves the Iterator on the next element.
bool hasNext ()
 Tells if the sequence is at its end.
- Public Member Functions inherited from tlp::Iterator< VALUE >
 Iterator ()
virtual ~Iterator ()

Detailed Description

template<typename VALUE, typename ITERATOR, typename FILTER>
class tlp::StlFilterIterator< VALUE, ITERATOR, FILTER >

Iterator that enables to filter a Stl Iterator.

Parameters
startItthe beginning of the iterator that should be filtered (begin())
endItthe end of the iterator that should be filtered (begin())
filterthe 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;
forEach(x, new StlFilterIterator<double, vector<double>::const_iterator>(vec.begin(), vec.end(), filter)) {
cout << x << endl;
}

Constructor & Destructor Documentation

template<typename VALUE , typename ITERATOR , typename FILTER >
tlp::StlFilterIterator< VALUE, ITERATOR, FILTER >::StlFilterIterator ( const ITERATOR &  startIt,
const ITERATOR &  endIt,
FILTER  filter 
)
inline

Member Function Documentation

template<typename VALUE , typename ITERATOR , typename FILTER >
bool tlp::StlFilterIterator< VALUE, ITERATOR, FILTER >::hasNext ( )
inlinevirtual

Tells if the sequence is at its end.

Returns
bool Whether there are more elements to iterate on.

Implements tlp::Iterator< VALUE >.

template<typename VALUE , typename ITERATOR , typename FILTER >
VALUE tlp::StlFilterIterator< VALUE, ITERATOR, FILTER >::next ( )
inlinevirtual

Moves the Iterator on the next element.

Returns
The current element pointed by the Iterator.

Implements tlp::Iterator< VALUE >.



Tulip Software by LaBRI Visualization Team    2001 - 2012