trsl logo

trsl::persistent_filter_iterator< Predicate, Iterator > Class Template Reference

Adaptation of boost::filter_iterator to allow an element to be selected multiple times. More...

#include <persistent_filter_iterator.hpp>

List of all members.

Public Member Functions

 persistent_filter_iterator (Predicate f, Iterator x, Iterator end_=Iterator())
 persistent_filter_iterator (Iterator x, Iterator end_=Iterator())
template<class OtherIterator >
 persistent_filter_iterator (persistent_filter_iterator< Predicate, OtherIterator > const &t, typename boost::enable_if_convertible< OtherIterator, Iterator >::type *=0)
Predicate predicate () const
Iterator end () const

Friends

class boost::iterator_core_access

Detailed Description

template<class Predicate, class Iterator>
class trsl::persistent_filter_iterator< Predicate, Iterator >

Adaptation of boost::filter_iterator to allow an element to be selected multiple times.

The class boost::filter_iterator is an example of boost::iterator_adaptor that allows iterating through a range, skipping elements that don't verify a predicate. In boost::filter_iterator, incrementing the iterator will always advance of at least one element. In persistent_filter_iterator, an incrementation will not advance to a next element until the predicate becomes false on the current element. This implies that the predicate has either some memory, or a pseudo-random behavior.

A persistent_filter_iterator thus iterates over a virtual range. Consequently, equality of two persistent_filter_iterator is only verified if they point to the same element in the original range and if their predicates are equal. Predicates must thus implement operator==. To see whether two different persistent_filter_iterator actually point to the same input range element, one can compare the underlying iterators available through the base() method.

The doc on boost::filter_iterator applies for this class, except for the small differences noted above.

Examples:

trsl_example2.cpp.

Definition at line 93 of file persistent_filter_iterator.hpp.


The documentation for this class was generated from the following file:
© Copyright 2007-2011 Renaud Detry.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt.)
Revised Wed Apr 6 16:30:07 2011.
SourceForge.net Logo