10 #ifndef TEUCHOS_FILTERED_ITERATOR_HPP
11 #define TEUCHOS_FILTERED_ITERATOR_HPP
27 template<
class IteratorType,
class Predicate>
37 typedef typename std::iterator_traits<IteratorType>::value_type
value_type;
39 typedef typename std::iterator_traits<IteratorType>::reference
reference;
41 typedef typename std::iterator_traits<IteratorType>::pointer
pointer;
43 typedef typename std::iterator_traits<IteratorType>::difference_type
difference_type;
57 Predicate pred_in = Predicate()
62 template<
class IteratorType2,
class Predicate2>
67 template<
class IteratorType2,
class Predicate2>
160 #ifndef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
167 #ifndef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
179 template<
class IteratorType,
class Predicate>
190 template<
class IteratorType,
class Predicate>
204 template<
class IteratorType,
class Predicate>
205 std::ostream& operator<<(std::ostream &out, const FilteredIterator<IteratorType,Predicate>& itr)
216 template<
class IteratorType,
class Predicate>
219 while (current_ != end_ && !pred_(*current_)) {
225 template<
class IteratorType,
class Predicate>
228 while (current_ != begin_ && !pred_(*current_)) {
234 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
237 template<
class IteratorType,
class Predicate>
240 const bool current_is_at_end = (current_ == end_);
242 "Error, trying to iterate " << *
this <<
" forward ++ past end!");
246 template<
class IteratorType,
class Predicate>
249 const bool current_is_at_begin = (current_ == begin_);
251 "Error, trying to iterate " << *
this <<
" backward -- past begin!");
255 #endif // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
261 #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()