|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_UTILS_CONTAINERS_FILTER_ITERATOR_H_
2 #define GENESIS_UTILS_CONTAINERS_FILTER_ITERATOR_H_
38 #include <type_traits>
57 template<
typename PredicateFunctor,
typename BaseIterator >
68 using value_type =
typename std::iterator_traits<BaseIterator>::value_type;
69 using reference =
typename std::iterator_traits<BaseIterator>::reference;
70 using const_reference =
typename std::iterator_traits<BaseIterator>::reference
const;
71 using pointer =
typename std::iterator_traits<BaseIterator>::pointer;
72 using difference_type =
typename std::iterator_traits<BaseIterator>::difference_type;
91 FilterIterator( PredicateFunctor unary_func, BaseIterator begin, BaseIterator
end = BaseIterator{} )
92 : predicate_( unary_func )
97 while(( current_ != end_ ) && ( !predicate_( *current_ ))) {
176 if( current_ == end_ ) {
199 return current_ == it.current_;
204 return !(*
this == it);
209 return current_ - it.current_ < 0;
219 return !(*
this > it);
224 return !(*
this < it);
238 }
while(( current_ != end_ ) && ( !predicate_( *current_ )));
247 PredicateFunctor predicate_;
249 BaseIterator current_;
271 template<
typename PredicateFunctor,
typename BaseIterator>
273 PredicateFunctor unary_func,
275 BaseIterator end = BaseIterator{}
277 return FilterIterator<PredicateFunctor, BaseIterator>( unary_func, begin, end );
284 template<
typename PredicateFunctor,
typename BaseIterator>
286 PredicateFunctor unary_func,
300 template<
typename PredicateFunctor,
typename Container>
302 PredicateFunctor unary_func,
307 unary_func, container.begin(), container.end()
310 unary_func, container.end(), container.end()
319 template<
typename PredicateFunctor,
typename Container>
321 PredicateFunctor unary_func,
322 Container
const& container
326 unary_func, container.begin(), container.end()
329 unary_func, container.end(), container.end()
337 #endif // include guard
~FilterIterator()=default
BaseIterator base() const
friend FilterIterator operator+(difference_type n, FilterIterator const &it)
const_reference operator*() const
bool operator<=(FilterIterator const &it) const
Iterator class that allows to filter an underlying iterator by skipping elements that do not satisfy ...
FilterIterator & operator+=(difference_type n)
FilterIterator & operator++()
typename std::iterator_traits< BaseIterator >::reference reference
typename std::iterator_traits< BaseIterator >::value_type value_type
typename std::iterator_traits< BaseIterator >::reference const const_reference
bool operator<(FilterIterator const &it) const
reference operator->() const
bool operator>=(FilterIterator const &it) const
Simple wrapper for typical begin() and end() iterators, to be used in range-based for loops.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
bool operator>(FilterIterator const &it) const
Range< FilterIterator< PredicateFunctor, BaseIterator > > make_filter_range(PredicateFunctor unary_func, BaseIterator begin, BaseIterator end)
Construct a filtering range, given the filter predicate function as well as the underlying base itera...
typename std::iterator_traits< BaseIterator >::pointer pointer
FilterIterator operator+(difference_type n) const
FilterIterator & operator=(FilterIterator const &)=default
bool operator!=(FilterIterator const &it) const
typename std::iterator_traits< BaseIterator >::difference_type difference_type
FilterIterator< PredicateFunctor, BaseIterator > make_filter_iterator(PredicateFunctor unary_func, BaseIterator begin, BaseIterator end=BaseIterator{})
Construct a filtering iterator, given the filter predicate function as well as the underlying base it...
std::input_iterator_tag iterator_category
FilterIterator operator++(int)
bool operator==(FilterIterator const &it) const
FilterIterator(PredicateFunctor unary_func, BaseIterator begin, BaseIterator end=BaseIterator{})
Construct a filtering iterator, given the filter predicate function as well as the underlying base it...