Lunchbox  1.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lunchbox::IndexIterator< S, C, T > Class Template Reference

Counter-based, as opposed to pointer-based, iterator for any container. More...

#include <indexIterator.h>

+ Inheritance diagram for lunchbox::IndexIterator< S, C, T >:
+ Collaboration diagram for lunchbox::IndexIterator< S, C, T >:

Public Member Functions

 IndexIterator (C *container, const size_t i)
 Construct an iterator for a given container and position. More...
 
 IndexIterator (const S &from)
 Copy-construct an iterator. More...
 
template<class U , class V , class W >
 IndexIterator (const IndexIterator< U, V, W > &from)
 Copy-construct an iterator. More...
 
S & operator= (const IndexIterator &rhs)
 Assign the container and position from another iterator. More...
 
template<class U , class W >
S & operator= (const IndexIterator< S, U, W > &rhs)
 Assign the container and position from another iterator. More...
 
S & operator++ ()
 Increment the iterator position. More...
 
S & operator-- ()
 Decrement the iterator position. More...
 
operator++ (int)
 Increment the iterator position. More...
 
operator-- (int)
 Decrement the iterator position. More...
 
operator+ (const size_t &n) const
 Increment the iterator position by a given amount. More...
 
S & operator+= (const size_t &n)
 Increment the iterator position by a given amount. More...
 
operator- (const size_t &n) const
 Decrement the iterator position by a given amount. More...
 
S & operator-= (const size_t &n)
 Decrement the iterator position by a given amount. More...
 
ssize_t operator- (const S &n) const
 Compute the distance between this and another iterator. More...
 
bool operator== (const S &rhs) const
 
bool operator!= (const S &rhs) const
 
bool operator< (const S &rhs) const
 
bool operator> (const S &rhs) const
 
bool operator<= (const S &rhs) const
 
bool operator>= (const S &rhs) const
 
size_t getPosition () const
 

Protected Attributes

C * container_
 
size_t i_
 

Friends

template<class , class , class >
class IndexIterator
 

Detailed Description

template<class S, class C, class T>
class lunchbox::IndexIterator< S, C, T >

Counter-based, as opposed to pointer-based, iterator for any container.

Uses curiously recurring template pattern to return proper type from assignment and other operators. Access methods are to be implemented by a subclass using container_ and i_. Furthermore subclasses need to implement the necessary constructors (see LFVectorIterator for example).

Parameters
SCRTP Subclass type
CThe container type
TThe element type

Definition at line 38 of file indexIterator.h.

Constructor & Destructor Documentation

template<class S, class C, class T>
lunchbox::IndexIterator< S, C, T >::IndexIterator ( C *  container,
const size_t  i 
)
inline

Construct an iterator for a given container and position.

Version
1.8

Definition at line 43 of file indexIterator.h.

template<class S, class C, class T>
lunchbox::IndexIterator< S, C, T >::IndexIterator ( const S &  from)
inlineexplicit

Copy-construct an iterator.

Version
1.8

Definition at line 47 of file indexIterator.h.

template<class S, class C, class T>
template<class U , class V , class W >
lunchbox::IndexIterator< S, C, T >::IndexIterator ( const IndexIterator< U, V, W > &  from)
inline

Copy-construct an iterator.

Version
1.8

Definition at line 52 of file indexIterator.h.

Member Function Documentation

template<class S, class C, class T>
size_t lunchbox::IndexIterator< S, C, T >::getPosition ( ) const
inline
Returns
the position of this iterator.
Version
1.8

Definition at line 135 of file indexIterator.h.

template<class S, class C, class T>
bool lunchbox::IndexIterator< S, C, T >::operator!= ( const S &  rhs) const
inline
Returns
true if both iterators are not equal.
Version
1.8

Definition at line 109 of file indexIterator.h.

template<class S, class C, class T>
S lunchbox::IndexIterator< S, C, T >::operator+ ( const size_t &  n) const
inline

Increment the iterator position by a given amount.

Version
1.8

Definition at line 86 of file indexIterator.h.

template<class S, class C, class T>
S& lunchbox::IndexIterator< S, C, T >::operator++ ( void  )
inline

Increment the iterator position.

Version
1.8

Definition at line 74 of file indexIterator.h.

template<class S, class C, class T>
S lunchbox::IndexIterator< S, C, T >::operator++ ( int  )
inline

Increment the iterator position.

Version
1.8

Definition at line 80 of file indexIterator.h.

template<class S, class C, class T>
S& lunchbox::IndexIterator< S, C, T >::operator+= ( const size_t &  n)
inline

Increment the iterator position by a given amount.

Version
1.8

Definition at line 90 of file indexIterator.h.

template<class S, class C, class T>
S lunchbox::IndexIterator< S, C, T >::operator- ( const size_t &  n) const
inline

Decrement the iterator position by a given amount.

Version
1.8

Definition at line 94 of file indexIterator.h.

template<class S, class C, class T>
ssize_t lunchbox::IndexIterator< S, C, T >::operator- ( const S &  n) const
inline

Compute the distance between this and another iterator.

Version
1.8

Definition at line 102 of file indexIterator.h.

template<class S, class C, class T>
S& lunchbox::IndexIterator< S, C, T >::operator-- ( void  )
inline

Decrement the iterator position.

Version
1.8

Definition at line 77 of file indexIterator.h.

template<class S, class C, class T>
S lunchbox::IndexIterator< S, C, T >::operator-- ( int  )
inline

Decrement the iterator position.

Version
1.8

Definition at line 83 of file indexIterator.h.

template<class S, class C, class T>
S& lunchbox::IndexIterator< S, C, T >::operator-= ( const size_t &  n)
inline

Decrement the iterator position by a given amount.

Version
1.8

Definition at line 98 of file indexIterator.h.

template<class S, class C, class T>
bool lunchbox::IndexIterator< S, C, T >::operator< ( const S &  rhs) const
inline
Returns
true if this iterator is before the given one.
Version
1.8

Definition at line 113 of file indexIterator.h.

template<class S, class C, class T>
bool lunchbox::IndexIterator< S, C, T >::operator<= ( const S &  rhs) const
inline
Returns
true if this iterator is before or equal to the given one.
Version
1.8

Definition at line 124 of file indexIterator.h.

template<class S, class C, class T>
S& lunchbox::IndexIterator< S, C, T >::operator= ( const IndexIterator< S, C, T > &  rhs)
inline

Assign the container and position from another iterator.

Version
1.8

Definition at line 57 of file indexIterator.h.

template<class S, class C, class T>
template<class U , class W >
S& lunchbox::IndexIterator< S, C, T >::operator= ( const IndexIterator< S, U, W > &  rhs)
inline

Assign the container and position from another iterator.

Version
1.8

Definition at line 66 of file indexIterator.h.

template<class S, class C, class T>
bool lunchbox::IndexIterator< S, C, T >::operator== ( const S &  rhs) const
inline
Returns
true if both iterators are equal.
Version
1.8

Definition at line 105 of file indexIterator.h.

template<class S, class C, class T>
bool lunchbox::IndexIterator< S, C, T >::operator> ( const S &  rhs) const
inline
Returns
true if this iterator is after the given one.
Version
1.8

Definition at line 117 of file indexIterator.h.

template<class S, class C, class T>
bool lunchbox::IndexIterator< S, C, T >::operator>= ( const S &  rhs) const
inline
Returns
true if this iterator is after or equal to the given one.
Version
1.8

Definition at line 131 of file indexIterator.h.


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