CGAL::Filter_iterator<Iterator, Predicate>


The iterator adaptor Filter_iterator<Iterator, Predicate> acts as a filter on a given range. Whenever the iterator is in- or decremented, it ignores all iterators for which the given Predicate is true. The iterator category is the same as for Iterator.

Note: Boost also provides the same functionality via the boost::filter_iterator class. Unfortunately, the semantics chosen for accepting or rejecting elements based on the predicate's result are opposite as the semantic chosen here. What is more, the argument of the predicate is different: the predicate used with boost::filter_iterator must take the value type of the iterator, as argument, and not the iterator itself.

#include <CGAL/iterator.h>



Filter_iterator<Iterator, Predicate> i;

Filter_iterator<Iterator, Predicate> i ( Iterator e, Predicate p, Iterator c = e);
creates an iterator which filters values according to p. Initializes by taking the first valid iterator (according to p), starting at c, and stopping at e if none is found.

There is also a global function to help the use of Filter_iterator<Iterator, Predicate>:

template < class Iterator, class Predicate >
inline Filter_iterator< Iterator, Predicate >
filter_iterator ( Iterator e, Predicate p, Iterator c = e)
Constructs Filter_iterator<Iterator, Predicate>(e, p, c).