Calico
 All Classes Namespaces Files Functions Variables Typedefs Friends Groups
cal::counted_iterator< Iterator, Distance > Struct Template Reference

An iterator adapter that counts the offset as the iterator moves. More...

#include <iterator.hpp>

Public Types

typedef Distance difference_type
 Difference type (also used for counting).
 
typedef std::iterator_traits
< iterator_type >
::iterator_category 
iterator_category
 Iterator category.
 
typedef Iterator iterator_type
 Underlying iterator type.
 
typedef std::iterator_traits
< iterator_type >::pointer 
pointer
 Pointer type.
 
typedef std::iterator_traits
< iterator_type >::reference 
reference
 Reference type.
 
typedef std::iterator_traits
< iterator_type >::value_type 
value_type
 Value type.
 

Public Member Functions

 counted_iterator ()
 Default initializes the iterator with an unspecified counter value.
 
 counted_iterator (const iterator_type &iterator, difference_type init_count=difference_type())
 Constructs a counted_iterator with an initial count. More...
 
const iterator_typebase () const
 Returns the underlying iterator.
 
difference_type count () const
 Returns the current value of the counter.
 
 operator iterator_type () const
 Returns the underlying iterator.
 
reference operator* () const
 Returns the pointed-to object.
 
counted_iterator operator++ (int)
 Post-increments the underlying iterator and the counter.
 
counted_iteratoroperator++ ()
 Pre-increments the underlying iterator and the counter.
 
template<class N >
counted_iteratoroperator+= (N n)
 Advances both the underlying iterator and the counter by n.
 
counted_iteratoroperator-- ()
 Pre-decrements the underlying iterator and the counter.
 
counted_iterator operator-- (int)
 Post-decrements the underlying iterator and the counter.
 
template<class N >
counted_iteratoroperator-= (N n)
 Advances both the underlying iterator and the counter by n in reverse.
 
pointer operator-> () const
 Member access of the object pointed to by the iterator.
 
void set_count (difference_type value)
 Sets the current value of the counter.
 

Detailed Description

template<class Iterator, class Distance = std::iterator_traits<Iterator>::difference_type>
struct cal::counted_iterator< Iterator, Distance >

An iterator adapter that counts the offset as the iterator moves.

Template Parameters
IteratorAn iterator type to be wrapped. The adapter supports all kinds of iterators.
DistanceThe type used to count the iterations. Defaults to the difference_type of the Iterator.

Constructor & Destructor Documentation

template<class Iterator , class Distance = std::iterator_traits<Iterator>::difference_type>
cal::counted_iterator< Iterator, Distance >::counted_iterator ( const iterator_type iterator,
difference_type  init_count = difference_type() 
)
inline

Constructs a counted_iterator with an initial count.

Parameters
iteratorThe iterator to be wrapped.
init_countThe initial count.