retdec
|
An adapter of an iterator range in which some elements of the range are skipped. More...
#include <filter_iterator.h>
Public Types | |
using | value_type = typename std::iterator_traits< Iterator >::value_type |
using | reference = typename std::iterator_traits< Iterator >::reference |
using | pointer = typename std::iterator_traits< Iterator >::pointer |
using | difference_type = typename std::iterator_traits< Iterator >::difference_type |
using | iterator_category = std::forward_iterator_tag |
Public Member Functions | |
template<typename Predicate > | |
FilterIterator (Iterator begin, Iterator end, Predicate &&predicate) | |
Creates an iterator over the given range. More... | |
template<typename Container , typename Predicate > | |
FilterIterator (Container &container, Predicate &&predicate) | |
Creates an iterator over the given container. More... | |
FilterIterator (Iterator end) | |
Creates an end iterator. More... | |
FilterIterator (const FilterIterator &other)=default | |
FilterIterator (FilterIterator &&other)=default | |
~FilterIterator ()=default | |
FilterIterator & | operator= (const FilterIterator &other)=default |
reference | operator* () const |
pointer | operator-> () const |
bool | operator== (const FilterIterator &other) const |
bool | operator!= (const FilterIterator &other) const |
FilterIterator & | operator++ () |
Private Member Functions | |
void | skipElementsWhilePredicateIsFalse () |
Private Attributes | |
Iterator | current |
Iterator | end |
std::function< bool(reference)> | predicate |
An adapter of an iterator range in which some elements of the range are skipped.
The filter iterator adapter creates a view of an iterator range in which some elements of the range are skipped. A predicate function object controls which elements are skipped. When the predicate is applied to an element, if it returns true, then the element is retained, and if it returns false, then the element is skipped over. When skipping over elements, it is necessary for the filter adapter to know when to stop so as to avoid going past the end of the underlying range. A filter iterator is, therefore, constructed with pair of iterators indicating the range of elements in the unfiltered sequence to be traversed and a predicate.
Based on filter_iterator from Boost (http://www.boost.org/doc/libs/master/libs/iterator/doc/filter_iterator.html). See it for more information. Note, however, that our interface differs from the one provided by Boost.
Iterator | Type of the iterators in the range. |
using retdec::utils::FilterIterator< Iterator >::difference_type = typename std::iterator_traits<Iterator>::difference_type |
using retdec::utils::FilterIterator< Iterator >::iterator_category = std::forward_iterator_tag |
using retdec::utils::FilterIterator< Iterator >::pointer = typename std::iterator_traits<Iterator>::pointer |
using retdec::utils::FilterIterator< Iterator >::reference = typename std::iterator_traits<Iterator>::reference |
using retdec::utils::FilterIterator< Iterator >::value_type = typename std::iterator_traits<Iterator>::value_type |
|
inline |
Creates an iterator over the given range.
[in] | begin | Start of the range. |
[in] | end | End of the range. |
[in] | predicate | Predicate for determining which elements should be retained. |
|
inline |
Creates an iterator over the given container.
[in] | container | Container to be iterated. |
[in] | predicate | Predicate for determining which elements should be retained. |
This constructor is a handy alias for the following code:
|
inline |
Creates an end iterator.
|
default |
|
default |
|
default |
|
inline |
|
inline |
|
inline |
|
inline |
|
default |
|
inline |
|
inlineprivate |
|
private |
|
private |
|
private |