CBMC
filter_iteratort< iteratort > Class Template Reference

Iterator which only stops at elements for which some given function f is true. More...

#include <range.h>

+ Collaboration diagram for filter_iteratort< iteratort >:

Public Types

using difference_type = typename iteratort::difference_type
 
using value_type = typename iteratort::value_type
 
using pointer = typename iteratort::pointer
 
using reference = typename iteratort::reference
 
using iterator_category = std::forward_iterator_tag
 

Public Member Functions

bool operator== (const filter_iteratort &other) const
 
bool operator!= (const filter_iteratort &other) const
 
filter_iteratortoperator++ ()
 Preincrement operator. More...
 
filter_iteratort operator++ (int)
 Postincrement operator. More...
 
reference operator* () const
 
pointer operator-> () const
 
 filter_iteratort (std::shared_ptr< std::function< bool(const value_type &)>> f, iteratort underlying, iteratort end)
 Filter between underlying and end using f. More...
 

Private Member Functions

void point_to_first_to_peek ()
 Ensure that the underlying iterator is always positioned on an element for which f is true. More...
 

Private Attributes

iteratort underlying
 
const iteratort underlying_end
 
std::shared_ptr< std::function< bool(const value_type &)> > f
 

Detailed Description

template<typename iteratort>
class filter_iteratort< iteratort >

Iterator which only stops at elements for which some given function f is true.

Definition at line 111 of file range.h.

Member Typedef Documentation

◆ difference_type

template<typename iteratort >
using filter_iteratort< iteratort >::difference_type = typename iteratort::difference_type

Definition at line 114 of file range.h.

◆ iterator_category

template<typename iteratort >
using filter_iteratort< iteratort >::iterator_category = std::forward_iterator_tag

Definition at line 118 of file range.h.

◆ pointer

template<typename iteratort >
using filter_iteratort< iteratort >::pointer = typename iteratort::pointer

Definition at line 116 of file range.h.

◆ reference

template<typename iteratort >
using filter_iteratort< iteratort >::reference = typename iteratort::reference

Definition at line 117 of file range.h.

◆ value_type

template<typename iteratort >
using filter_iteratort< iteratort >::value_type = typename iteratort::value_type

Definition at line 115 of file range.h.

Constructor & Destructor Documentation

◆ filter_iteratort()

template<typename iteratort >
filter_iteratort< iteratort >::filter_iteratort ( std::shared_ptr< std::function< bool(const value_type &)>>  f,
iteratort  underlying,
iteratort  end 
)
inline

Filter between underlying and end using f.

If f is not true for any element between underlying and end, the constructed iterator is equal to the one which would have been constructed using

filter_iteratort(f, end, end)
std::shared_ptr< std::function< bool(const value_type &)> > f
Definition: range.h:177
filter_iteratort(std::shared_ptr< std::function< bool(const value_type &)>> f, iteratort underlying, iteratort end)
Filter between underlying and end using f.
Definition: range.h:163

Definition at line 163 of file range.h.

Member Function Documentation

◆ operator!=()

template<typename iteratort >
bool filter_iteratort< iteratort >::operator!= ( const filter_iteratort< iteratort > &  other) const
inline

Definition at line 125 of file range.h.

◆ operator*()

template<typename iteratort >
reference filter_iteratort< iteratort >::operator* ( ) const
inline

Definition at line 146 of file range.h.

◆ operator++() [1/2]

template<typename iteratort >
filter_iteratort& filter_iteratort< iteratort >::operator++ ( )
inline

Preincrement operator.

Definition at line 131 of file range.h.

◆ operator++() [2/2]

template<typename iteratort >
filter_iteratort filter_iteratort< iteratort >::operator++ ( int  )
inline

Postincrement operator.

Definition at line 139 of file range.h.

◆ operator->()

template<typename iteratort >
pointer filter_iteratort< iteratort >::operator-> ( ) const
inline

Definition at line 151 of file range.h.

◆ operator==()

template<typename iteratort >
bool filter_iteratort< iteratort >::operator== ( const filter_iteratort< iteratort > &  other) const
inline

Definition at line 120 of file range.h.

◆ point_to_first_to_peek()

template<typename iteratort >
void filter_iteratort< iteratort >::point_to_first_to_peek ( )
inlineprivate

Ensure that the underlying iterator is always positioned on an element for which f is true.

This does nothing if f is satisfied at the current position. If f is not true for any element between underlying and underlying_end underlying will be incremented until underlying_end is reached.

Definition at line 184 of file range.h.

Member Data Documentation

◆ f

template<typename iteratort >
std::shared_ptr<std::function<bool(const value_type &)> > filter_iteratort< iteratort >::f
private

Definition at line 177 of file range.h.

◆ underlying

template<typename iteratort >
iteratort filter_iteratort< iteratort >::underlying
private

Definition at line 175 of file range.h.

◆ underlying_end

template<typename iteratort >
const iteratort filter_iteratort< iteratort >::underlying_end
private

Definition at line 176 of file range.h.


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