#include <genesis/utils/containers/filter_iterator.hpp>
template<typename PredicateFunctor, typename BaseIterator>
class genesis::utils::FilterIterator< PredicateFunctor, BaseIterator >
Iterator class that allows to filter an underlying iterator by skipping elements that do not satisfy a given predicate.
The constructor is used to set the filter predicate function. See also make_filter_iterator() and make_filter_range() for helper functions to easily create an instance.
Inspired by the Boost Filter Iterator (https://www.boost.org/doc/libs/1_67_0/libs/iterator/doc/html/iterator/specialized/filter.html), StackOverflow (https://stackoverflow.com/a/44350827/4184258), and Jez Higgins (https://www.jezuk.co.uk/blog/2008/02/a-filtering-iterator-in-c.html).
Definition at line 58 of file filter_iterator.hpp.
◆ FilterIterator() [1/3]
FilterIterator |
( |
PredicateFunctor |
unary_func, |
|
|
BaseIterator |
begin, |
|
|
BaseIterator |
end = BaseIterator{} |
|
) |
| |
|
inline |
Construct a filtering iterator, given the filter predicate function as well as the underlying base iterator begin and end.
Caveat: Note that by default, we use a default-constructed end
iterator. This only works for containers where the default-constructed iterator is the end iterator! In particular, this does NOT work for many STL containers. For example, for a std::vector
, one needs to explicitly use vector.end()
here.
This constructor needs to be used for both the begin and end of the range that one wants to iterate, using the same filter function both times. See also make_filter_iterator() and make_filter_range() for helper functions to easily create an instance.
Definition at line 91 of file filter_iterator.hpp.
◆ ~FilterIterator()
◆ FilterIterator() [2/3]
◆ FilterIterator() [3/3]
◆ base()
BaseIterator base |
( |
| ) |
const |
|
inline |
◆ end()
BaseIterator end |
( |
| ) |
const |
|
inline |
◆ operator!=()
bool operator!= |
( |
FilterIterator< PredicateFunctor, BaseIterator > const & |
it | ) |
const |
|
inline |
◆ operator*() [1/2]
◆ operator*() [2/2]
◆ operator+()
◆ operator++() [1/2]
◆ operator++() [2/2]
◆ operator+=()
◆ operator->()
◆ operator<()
bool operator< |
( |
FilterIterator< PredicateFunctor, BaseIterator > const & |
it | ) |
const |
|
inline |
◆ operator<=()
bool operator<= |
( |
FilterIterator< PredicateFunctor, BaseIterator > const & |
it | ) |
const |
|
inline |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ operator==()
bool operator== |
( |
FilterIterator< PredicateFunctor, BaseIterator > const & |
it | ) |
const |
|
inline |
◆ operator>()
bool operator> |
( |
FilterIterator< PredicateFunctor, BaseIterator > const & |
it | ) |
const |
|
inline |
◆ operator>=()
bool operator>= |
( |
FilterIterator< PredicateFunctor, BaseIterator > const & |
it | ) |
const |
|
inline |
◆ operator+
◆ const_reference
◆ difference_type
◆ iterator_category
◆ pointer
◆ reference
◆ value_type
The documentation for this class was generated from the following file: