\( \newcommand{\E}{\mathrm{E}} \) \( \newcommand{\A}{\mathrm{A}} \) \( \newcommand{\R}{\mathrm{R}} \) \( \newcommand{\N}{\mathrm{N}} \) \( \newcommand{\Q}{\mathrm{Q}} \) \( \newcommand{\Z}{\mathrm{Z}} \) \( \def\ccSum #1#2#3{ \sum_{#1}^{#2}{#3} } \def\ccProd #1#2#3{ \sum_{#1}^{#2}{#3} }\)
CGAL 5.0.1 - STL Extensions for CGAL
CGAL::Filter_iterator< Iterator, Predicate > Struct Template Reference

#include <CGAL/iterator.h>

Definition

The iterator adaptor Filter_iterator 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.

Attention
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.
Template Parameters
Iteratormust be a model of ForwardIterator
Predicatemust be a functor Iterator \( \rightarrow\) bool

Related Functions

(Note that these are not member functions.)

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

Creation

 Filter_iterator ()
 
 Filter_iterator (Iterator e, Predicate p, Iterator c=e)
 creates an iterator which filters values according to p. More...
 

Constructor & Destructor Documentation

◆ Filter_iterator()

template<typename Iterator , typename Predicate >
CGAL::Filter_iterator< Iterator, Predicate >::Filter_iterator ( 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.