cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Attributes | List of all members
vctFixedStrideVectorConstIterator< _elementType, _stride > Class Template Reference

#include <vctFixedStrideVectorIterator.h>

Inheritance diagram for vctFixedStrideVectorConstIterator< _elementType, _stride >:
vctFixedStrideVectorIterator< _elementType, _stride >

Public Types

enum  { STRIDE = _stride }
 
typedef
vctFixedStrideVectorConstIterator
< _elementType, _stride > 
ThisType
 
typedef std::iterator
< std::random_access_iterator_tag,
_elementType > 
BaseType
 
typedef BaseType::iterator_category iterator_category
 

Public Member Functions

 VCT_CONTAINER_TRAITS_TYPEDEFS (_elementType)
 
 vctFixedStrideVectorConstIterator ()
 
 vctFixedStrideVectorConstIterator (value_type *dataPtr)
 
 vctFixedStrideVectorConstIterator (const value_type *dataPtr)
 
ThisTypeoperator++ ()
 
ThisType operator++ (int)
 
ThisTypeoperator-- ()
 
ThisType operator-- (int)
 
ThisTypeoperator+= (difference_type difference)
 
ThisTypeoperator-= (difference_type difference)
 
difference_type operator- (const ThisType &other) const
 
const value_type & operator[] (difference_type index) const
 
const value_type & operator* () const
 
bool operator< (const ThisType &other) const
 
bool operator<= (const ThisType &other) const
 
bool operator== (const ThisType &other) const
 
bool operator> (const ThisType &other) const
 
bool operator>= (const ThisType &other) const
 
bool operator!= (const ThisType &other) const
 

Protected Attributes

value_type * DataPtr
 

Detailed Description

template<class _elementType, vct::stride_type _stride>
class vctFixedStrideVectorConstIterator< _elementType, _stride >

Define an iterator over a memory array with stride. The iterator is defined according to the STL specifications of random-access-iterarator. It is almost identical to std::vector::iterator, except that the ++, –, +=, -=, +, -, operations all work in _stride increments, and these are specified in compile time.

We first define a const iterator, which only allows to read the referenced object. The non-const iterator hass all the functionality of a const_iterator, plus the mutability of the objects. We therefore derive vctFixedStrideVectorIterator from vctFixedStrideVectorConstIterator (as done with std::list iterators).

In the current version, we do not define operator=, and rely on explicit declarations of objects and the default operator= and copy constructor.

Parameters
_stridethe stride between elements of the vector being iterated over.
_elementTypethe type of the element that the iterator refers to.
See Also
vctFixedStrideVectorIterator

Member Typedef Documentation

template<class _elementType, vct::stride_type _stride>
typedef std::iterator<std::random_access_iterator_tag, _elementType> vctFixedStrideVectorConstIterator< _elementType, _stride >::BaseType

Base type for this iterator, i.e. std::iterator.

template<class _elementType, vct::stride_type _stride>
typedef BaseType::iterator_category vctFixedStrideVectorConstIterator< _elementType, _stride >::iterator_category

Type (i.e. category) of iterator, i.e. std::random_access_iterator_tag.

template<class _elementType, vct::stride_type _stride>
typedef vctFixedStrideVectorConstIterator<_elementType, _stride> vctFixedStrideVectorConstIterator< _elementType, _stride >::ThisType

This of the iterator itself.

Member Enumeration Documentation

template<class _elementType, vct::stride_type _stride>
anonymous enum
Enumerator
STRIDE 

Constructor & Destructor Documentation

template<class _elementType, vct::stride_type _stride>
vctFixedStrideVectorConstIterator< _elementType, _stride >::vctFixedStrideVectorConstIterator ( )
inline

Default constructor: create an uninitialized object.

template<class _elementType, vct::stride_type _stride>
vctFixedStrideVectorConstIterator< _elementType, _stride >::vctFixedStrideVectorConstIterator ( value_type *  dataPtr)
inlineexplicit

Constructor taking a non-const element pointer. Note that only read operations will be performed!

template<class _elementType, vct::stride_type _stride>
vctFixedStrideVectorConstIterator< _elementType, _stride >::vctFixedStrideVectorConstIterator ( const value_type *  dataPtr)
inlineexplicit

Constructor taking a const element pointer. We need it in order to deal with const containers being refered by this iterator. We have to perform const_cast to convert back to the stored non-const member pointer of this iterator. However, the non-const iterator class completely shadows the constructors of the const-iterator base class, and so we don't have to worry about creating a non-const iterator over a const container.

Member Function Documentation

template<class _elementType, vct::stride_type _stride>
bool vctFixedStrideVectorConstIterator< _elementType, _stride >::operator!= ( const ThisType other) const
inline

Complementary operation to operator ==

template<class _elementType, vct::stride_type _stride>
const value_type& vctFixedStrideVectorConstIterator< _elementType, _stride >::operator* ( ) const
inline

Dereference (const)

template<class _elementType, vct::stride_type _stride>
ThisType& vctFixedStrideVectorConstIterator< _elementType, _stride >::operator++ ( )
inline

Pre-increment.

template<class _elementType, vct::stride_type _stride>
ThisType vctFixedStrideVectorConstIterator< _elementType, _stride >::operator++ ( int  )
inline

Post increment.

template<class _elementType, vct::stride_type _stride>
ThisType& vctFixedStrideVectorConstIterator< _elementType, _stride >::operator+= ( difference_type  difference)
inline

Increase by given difference.

template<class _elementType, vct::stride_type _stride>
difference_type vctFixedStrideVectorConstIterator< _elementType, _stride >::operator- ( const ThisType other) const
inline

Find difference between iterators. This method does not test for reachability, and may return invalid values if the two iterators are not reachable. It is the user's responsibility to ensure the correctness.

template<class _elementType, vct::stride_type _stride>
ThisType& vctFixedStrideVectorConstIterator< _elementType, _stride >::operator-- ( )
inline

Pre-decrement.

template<class _elementType, vct::stride_type _stride>
ThisType vctFixedStrideVectorConstIterator< _elementType, _stride >::operator-- ( int  )
inline

Post decrement.

template<class _elementType, vct::stride_type _stride>
ThisType& vctFixedStrideVectorConstIterator< _elementType, _stride >::operator-= ( difference_type  difference)
inline

Decrease by given difference.

template<class _elementType, vct::stride_type _stride>
bool vctFixedStrideVectorConstIterator< _elementType, _stride >::operator< ( const ThisType other) const
inline

Order relation between iterators, required by STL.

Note
The STL manual states that "if j is reachable from i then i<j". This does not imply the converse: "if i<j then j is reachable from i". In the case here, the converse does not hold.
template<class _elementType, vct::stride_type _stride>
bool vctFixedStrideVectorConstIterator< _elementType, _stride >::operator<= ( const ThisType other) const
inline
template<class _elementType, vct::stride_type _stride>
bool vctFixedStrideVectorConstIterator< _elementType, _stride >::operator== ( const ThisType other) const
inline

Equality of iterators, required by STL

template<class _elementType, vct::stride_type _stride>
bool vctFixedStrideVectorConstIterator< _elementType, _stride >::operator> ( const ThisType other) const
inline

Complementary operation to operator <

template<class _elementType, vct::stride_type _stride>
bool vctFixedStrideVectorConstIterator< _elementType, _stride >::operator>= ( const ThisType other) const
inline
template<class _elementType, vct::stride_type _stride>
const value_type& vctFixedStrideVectorConstIterator< _elementType, _stride >::operator[] ( difference_type  index) const
inline

Random access (return const reference).

template<class _elementType, vct::stride_type _stride>
vctFixedStrideVectorConstIterator< _elementType, _stride >::VCT_CONTAINER_TRAITS_TYPEDEFS ( _elementType  )

Member Data Documentation

template<class _elementType, vct::stride_type _stride>
value_type* vctFixedStrideVectorConstIterator< _elementType, _stride >::DataPtr
protected

The data member points to the object being refered by this iterator. It is not declared const, so we will be able to use it in the non-const iterator class. But all the methods in vctFixedStrideVectorConstIterator are declared const to protect the data from writing.


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