cisst-saw
Loading...
Searching...
No Matches
vctVarStrideVectorConstIterator< _elementType > Class Template Reference

#include <vctVarStrideVectorIterator.h>

Inheritance diagram for vctVarStrideVectorConstIterator< _elementType >:
vctVarStrideVectorIterator< _elementType >

Public Types

typedef vctVarStrideVectorConstIterator< _elementType > ThisType
typedef std::random_access_iterator_tag iterator_category

Public Member Functions

 VCT_CONTAINER_TRAITS_TYPEDEFS (_elementType)
 vctVarStrideVectorConstIterator ()
 vctVarStrideVectorConstIterator (value_type *dataPtr, difference_type stride=1)
 vctVarStrideVectorConstIterator (const value_type *dataPtr, difference_type stride=1)
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_typeoperator[] (difference_type index) const
const value_typeoperator* () 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_typeDataPtr
difference_type Stride

Detailed Description

template<class _elementType>
class vctVarStrideVectorConstIterator< _elementType >

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.

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 vctVarStrideVectorIterator from vctVarStrideVectorConstIterator (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
_elementTypethe type of the element that the iterator refers to.
See also
vctVarStrideVectorIterator

Member Typedef Documentation

◆ iterator_category

template<class _elementType>
typedef std::random_access_iterator_tag vctVarStrideVectorConstIterator< _elementType >::iterator_category

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

◆ ThisType

template<class _elementType>
typedef vctVarStrideVectorConstIterator<_elementType> vctVarStrideVectorConstIterator< _elementType >::ThisType

The type of the iterator itself.

Constructor & Destructor Documentation

◆ vctVarStrideVectorConstIterator() [1/3]

template<class _elementType>
vctVarStrideVectorConstIterator< _elementType >::vctVarStrideVectorConstIterator ( )
inline

Default constructor: create an uninitialized object.

◆ vctVarStrideVectorConstIterator() [2/3]

template<class _elementType>
vctVarStrideVectorConstIterator< _elementType >::vctVarStrideVectorConstIterator ( value_type * dataPtr,
difference_type stride = 1 )
inlineexplicit

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

◆ vctVarStrideVectorConstIterator() [3/3]

template<class _elementType>
vctVarStrideVectorConstIterator< _elementType >::vctVarStrideVectorConstIterator ( const value_type * dataPtr,
difference_type stride = 1 )
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

◆ operator!=()

template<class _elementType>
bool vctVarStrideVectorConstIterator< _elementType >::operator!= ( const ThisType & other) const
inline

Complementary operation to operator ==

◆ operator*()

template<class _elementType>
const value_type & vctVarStrideVectorConstIterator< _elementType >::operator* ( ) const
inline

Dereference (const)

◆ operator++() [1/2]

template<class _elementType>
ThisType & vctVarStrideVectorConstIterator< _elementType >::operator++ ( )
inline

Pre-increment.

◆ operator++() [2/2]

template<class _elementType>
ThisType vctVarStrideVectorConstIterator< _elementType >::operator++ ( int )
inline

Post increment.

◆ operator+=()

template<class _elementType>
ThisType & vctVarStrideVectorConstIterator< _elementType >::operator+= ( difference_type difference)
inline

Increase by given difference.

◆ operator-()

template<class _elementType>
difference_type vctVarStrideVectorConstIterator< _elementType >::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.

◆ operator--() [1/2]

template<class _elementType>
ThisType & vctVarStrideVectorConstIterator< _elementType >::operator-- ( )
inline

Pre-decrement.

◆ operator--() [2/2]

template<class _elementType>
ThisType vctVarStrideVectorConstIterator< _elementType >::operator-- ( int )
inline

Post decrement.

◆ operator-=()

template<class _elementType>
ThisType & vctVarStrideVectorConstIterator< _elementType >::operator-= ( difference_type difference)
inline

Decrease by given difference.

◆ operator<()

template<class _elementType>
bool vctVarStrideVectorConstIterator< _elementType >::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.

◆ operator<=()

template<class _elementType>
bool vctVarStrideVectorConstIterator< _elementType >::operator<= ( const ThisType & other) const
inline

◆ operator==()

template<class _elementType>
bool vctVarStrideVectorConstIterator< _elementType >::operator== ( const ThisType & other) const
inline

Equality of iterators, required by STL

◆ operator>()

template<class _elementType>
bool vctVarStrideVectorConstIterator< _elementType >::operator> ( const ThisType & other) const
inline

Complementary operation to operator <

◆ operator>=()

template<class _elementType>
bool vctVarStrideVectorConstIterator< _elementType >::operator>= ( const ThisType & other) const
inline

◆ operator[]()

template<class _elementType>
const value_type & vctVarStrideVectorConstIterator< _elementType >::operator[] ( difference_type index) const
inline

Random access (return const reference).

◆ VCT_CONTAINER_TRAITS_TYPEDEFS()

template<class _elementType>
vctVarStrideVectorConstIterator< _elementType >::VCT_CONTAINER_TRAITS_TYPEDEFS ( _elementType )

Member Data Documentation

◆ DataPtr

template<class _elementType>
value_type* vctVarStrideVectorConstIterator< _elementType >::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 vctVarStrideVectorConstIterator are declared const to protect the data from writing.

◆ Stride

template<class _elementType>
difference_type vctVarStrideVectorConstIterator< _elementType >::Stride
protected

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