CGAL 6.2 - STL Extensions for CGAL: CGAL::Filter_iterator< Iterator, Predicate > Struct Template Reference

CGAL 6.2 - STL Extensions for CGAL

Loading...
Searching...
No Matches
List of all members | Related Functions
CGAL::Filter_iterator< Iterator, Predicate > Struct Template Reference
Reference Manual » Iterators and Iterator/Circulator Adaptors

`#include <CGAL/iterator.h>`

## Definition

template<typename Iterator, typename Predicate>
struct CGAL::Filter_iterator< Iterator, Predicate >

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

  Iterator | must be a model of `ForwardIterator`
  Predicate | must 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`.

## 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.