42 #ifndef TEUCHOS_FILTERED_ITERATOR_HPP
43 #define TEUCHOS_FILTERED_ITERATOR_HPP
59 template<
class IteratorType,
class Predicate>
69 typedef typename std::iterator_traits<IteratorType>::value_type
value_type;
71 typedef typename std::iterator_traits<IteratorType>::reference
reference;
73 typedef typename std::iterator_traits<IteratorType>::pointer
pointer;
75 typedef typename std::iterator_traits<IteratorType>::difference_type
difference_type;
89 Predicate pred_in = Predicate()
94 template<
class IteratorType2,
class Predicate2>
99 template<
class IteratorType2,
class Predicate2>
192 #ifndef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
199 #ifndef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
211 template<
class IteratorType,
class Predicate>
222 template<
class IteratorType,
class Predicate>
236 template<
class IteratorType,
class Predicate>
237 std::ostream& operator<<(std::ostream &out, const FilteredIterator<IteratorType,Predicate>& itr)
248 template<
class IteratorType,
class Predicate>
251 while (current_ != end_ && !pred_(*current_)) {
257 template<
class IteratorType,
class Predicate>
260 while (current_ != begin_ && !pred_(*current_)) {
266 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
269 template<
class IteratorType,
class Predicate>
272 const bool current_is_at_end = (current_ == end_);
274 "Error, trying to iterate " << *
this <<
" forward ++ past end!");
278 template<
class IteratorType,
class Predicate>
281 const bool current_is_at_begin = (current_ == begin_);
283 "Error, trying to iterate " << *
this <<
" backward -- past begin!");
287 #endif // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
293 #endif // TEUCHOS_FILTERED_ITERATOR_HPP
FilteredIterator(IteratorType current_in, IteratorType begin_in, IteratorType end_in, Predicate pred_in=Predicate())
Construct with iterator and range.
C++ Standard Library compatable filtered iterator.
const FilteredIterator operator--(int)
itr–
void advanceForwardToValid()
const FilteredIterator operator++(int)
itr++
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
std::iterator_traits< IteratorType >::pointer pointer
std::iterator_traits< IteratorType >::difference_type difference_type
std::iterator_traits< IteratorType >::value_type value_type
FilteredIterator()
construct to a null iterator.
bool operator!=(const FilteredIterator< IteratorType, Predicate > &itr1, const FilteredIterator< IteratorType, Predicate > &itr2)
itr1 != itr2.
bool operator==(const FilteredIterator< IteratorType, Predicate > &itr1, const FilteredIterator< IteratorType, Predicate > &itr2)
itr1 == itr2.
IteratorType current() const
FilteredIterator & operator--()
–itr
std::iterator_traits< IteratorType >::reference reference
void advanceBackwardToValid()
reference operator*() const
itr*
FilteredIterator & operator=(const FilteredIterator< IteratorType2, Predicate2 > &rhs)
Assign different types of iterators (mainly for non-const to const).
std::bidirectional_iterator_tag iterator_category
FilteredIterator & operator++()
++itr
IteratorType begin() const
FilteredIterator(const FilteredIterator< IteratorType2, Predicate2 > &rhs)
Convert type of iterators (mainly for non-const to const).
void assertNotIterateBackwardPastBegin()
Range error exception class.
void assertNotIterateForwardPastEnd()
Defines basic traits returning the name of a type in a portable and readable way. ...
pointer operator->() const
itr->member
static std::string name()