swift
Loading...
Searching...
No Matches
swift::misc::Iterators::ConditionalIterator< I, F > Class Template Reference

Iterator wrapper which skips over any elements which do not satisfy a given condition predicate. More...

#include <iterator.h>

Public Types

using iterator_category = std::forward_iterator_tag
 Types.
using value_type = typename std::iterator_traits<I>::value_type
 Types.
using difference_type = typename std::iterator_traits<I>::difference_type
 Types.
using pointer = typename std::iterator_traits<I>::pointer
 Types.
using reference = typename std::iterator_traits<I>::reference
 Types.

Public Member Functions

 ConditionalIterator (I iterator, I end, F predicate)
 Constructor.
 ConditionalIterator (I end)
 Implicit conversion from an end iterator.
I operator-> ()
 Indirection operator, returns the underlying iterator. Undefined if iterator is at the end.
std::iterator_traits< I >::reference operator* ()
 Dereference operator, returns the object referenced by the iterator. Undefined if iterator is at the end.
ConditionalIterator & operator++ ()
 Advance the iterator to the next element which matches the predicate, or the end if there are none remaining. Undefined if the iterator is already at the end.
ConditionalIterator operator++ (int)
 Advance the iterator to the next element which matches the predicate, or the end if there are none remaining. Undefined if the iterator is already at the end.
bool operator== (const ConditionalIterator &other) const
 Comparison operators.
bool operator!= (const ConditionalIterator &other) const
 Comparison operators.
bool operator< (const ConditionalIterator &other) const
 Comparison operators.
bool operator<= (const ConditionalIterator &other) const
 Comparison operators.
bool operator> (const ConditionalIterator &other) const
 Comparison operators.
bool operator>= (const ConditionalIterator &other) const
 Comparison operators.

Detailed Description

template<class I, class F>
class swift::misc::Iterators::ConditionalIterator< I, F >

Iterator wrapper which skips over any elements which do not satisfy a given condition predicate.

By creating a CRange from such iterators, it is possible to return the results of predicate methods without copying elements.

Definition at line 202 of file iterator.h.

Member Typedef Documentation

◆ difference_type

template<class I, class F>
using swift::misc::Iterators::ConditionalIterator< I, F >::difference_type = typename std::iterator_traits<I>::difference_type

Types.

Definition at line 209 of file iterator.h.

◆ iterator_category

template<class I, class F>
using swift::misc::Iterators::ConditionalIterator< I, F >::iterator_category = std::forward_iterator_tag

Types.

Definition at line 207 of file iterator.h.

◆ pointer

template<class I, class F>
using swift::misc::Iterators::ConditionalIterator< I, F >::pointer = typename std::iterator_traits<I>::pointer

Types.

Definition at line 210 of file iterator.h.

◆ reference

template<class I, class F>
using swift::misc::Iterators::ConditionalIterator< I, F >::reference = typename std::iterator_traits<I>::reference

Types.

Definition at line 211 of file iterator.h.

◆ value_type

template<class I, class F>
using swift::misc::Iterators::ConditionalIterator< I, F >::value_type = typename std::iterator_traits<I>::value_type

Types.

Definition at line 208 of file iterator.h.

Constructor & Destructor Documentation

◆ ConditionalIterator() [1/2]

template<class I, class F>
swift::misc::Iterators::ConditionalIterator< I, F >::ConditionalIterator ( I iterator,
I end,
F predicate )
inline

Constructor.

Definition at line 215 of file iterator.h.

◆ ConditionalIterator() [2/2]

template<class I, class F>
swift::misc::Iterators::ConditionalIterator< I, F >::ConditionalIterator ( I end)
inline

Implicit conversion from an end iterator.

Definition at line 224 of file iterator.h.

Member Function Documentation

◆ operator!=()

template<class I, class F>
bool swift::misc::Iterators::ConditionalIterator< I, F >::operator!= ( const ConditionalIterator< I, F > & other) const
inline

Comparison operators.

Definition at line 258 of file iterator.h.

◆ operator*()

template<class I, class F>
std::iterator_traits< I >::reference swift::misc::Iterators::ConditionalIterator< I, F >::operator* ( )
inline

Dereference operator, returns the object referenced by the iterator. Undefined if iterator is at the end.

Definition at line 253 of file iterator.h.

◆ operator++() [1/2]

template<class I, class F>
ConditionalIterator & swift::misc::Iterators::ConditionalIterator< I, F >::operator++ ( )
inline

Advance the iterator to the next element which matches the predicate, or the end if there are none remaining. Undefined if the iterator is already at the end.

Definition at line 229 of file iterator.h.

◆ operator++() [2/2]

template<class I, class F>
ConditionalIterator swift::misc::Iterators::ConditionalIterator< I, F >::operator++ ( int )
inline

Advance the iterator to the next element which matches the predicate, or the end if there are none remaining. Undefined if the iterator is already at the end.

Definition at line 239 of file iterator.h.

◆ operator->()

template<class I, class F>
I swift::misc::Iterators::ConditionalIterator< I, F >::operator-> ( )
inline

Indirection operator, returns the underlying iterator. Undefined if iterator is at the end.

Definition at line 249 of file iterator.h.

◆ operator<()

template<class I, class F>
bool swift::misc::Iterators::ConditionalIterator< I, F >::operator< ( const ConditionalIterator< I, F > & other) const
inline

Comparison operators.

Definition at line 259 of file iterator.h.

◆ operator<=()

template<class I, class F>
bool swift::misc::Iterators::ConditionalIterator< I, F >::operator<= ( const ConditionalIterator< I, F > & other) const
inline

Comparison operators.

Definition at line 260 of file iterator.h.

◆ operator==()

template<class I, class F>
bool swift::misc::Iterators::ConditionalIterator< I, F >::operator== ( const ConditionalIterator< I, F > & other) const
inline

Comparison operators.

Definition at line 257 of file iterator.h.

◆ operator>()

template<class I, class F>
bool swift::misc::Iterators::ConditionalIterator< I, F >::operator> ( const ConditionalIterator< I, F > & other) const
inline

Comparison operators.

Definition at line 261 of file iterator.h.

◆ operator>=()

template<class I, class F>
bool swift::misc::Iterators::ConditionalIterator< I, F >::operator>= ( const ConditionalIterator< I, F > & other) const
inline

Comparison operators.

Definition at line 262 of file iterator.h.


The documentation for this class was generated from the following file: