DGtal  0.9.4.1
Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Friends
DGtal::IntegerSequenceIterator< TInteger > Class Template Reference

#include <DGtal/base/IntegerSequenceIterator.h>

Inheritance diagram for DGtal::IntegerSequenceIterator< TInteger >:
[legend]
Collaboration diagram for DGtal::IntegerSequenceIterator< TInteger >:
[legend]

Public Types

typedef IntegerSequenceIterator< TInteger > Self
 
typedef TInteger Integer
 

Public Member Functions

 IntegerSequenceIterator (Integer n=Integer(0))
 
 ~IntegerSequenceIterator ()=default
 
 IntegerSequenceIterator (const IntegerSequenceIterator &other)=default
 
 IntegerSequenceIterator (IntegerSequenceIterator &&other)=default
 
IntegerSequenceIteratoroperator= (const IntegerSequenceIterator &other)=default
 
IntegerSequenceIteratoroperator= (IntegerSequenceIterator &&other)=default
 

Protected Attributes

Integer myNumber
 

Private Member Functions

void increment ()
 
void decrement ()
 
void advance (std::ptrdiff_t n)
 
std::ptrdiff_t distance_to (IntegerSequenceIterator const &other)
 
bool equal (IntegerSequenceIterator const &other) const
 
Integer const & dereference () const
 

Friends

class boost::iterator_core_access
 

Detailed Description

template<typename TInteger>
class DGtal::IntegerSequenceIterator< TInteger >

Aim: It is a simple class that mimics a (non mutable) iterator over integers. You can increment it, decrement it, displace it, compare it, etc. It is useful if you have a collection of consecutive integers, and you wish to create an iterator over it. It is used in the class TriangulatedSurface for example, since vertices are numbers from 0 to nbVertices - 1.

Description of template class 'IntegerSequenceIterator'

It is model of boost::RandomAccessIterator.

Definition at line 65 of file IntegerSequenceIterator.h.

Member Typedef Documentation

◆ Integer

template<typename TInteger >
typedef TInteger DGtal::IntegerSequenceIterator< TInteger >::Integer

Definition at line 72 of file IntegerSequenceIterator.h.

◆ Self

template<typename TInteger >
typedef IntegerSequenceIterator<TInteger> DGtal::IntegerSequenceIterator< TInteger >::Self

Definition at line 71 of file IntegerSequenceIterator.h.

Constructor & Destructor Documentation

◆ IntegerSequenceIterator() [1/3]

template<typename TInteger >
DGtal::IntegerSequenceIterator< TInteger >::IntegerSequenceIterator ( Integer  n = Integer( 0 ))
inline

Constructor from Integer;

Parameters
nany integer (default to zero).

Definition at line 81 of file IntegerSequenceIterator.h.

81 : myNumber( n ) {}
Integer myNumber
The current value of the interator.

◆ ~IntegerSequenceIterator()

template<typename TInteger >
DGtal::IntegerSequenceIterator< TInteger >::~IntegerSequenceIterator ( )
default

Destructor.

◆ IntegerSequenceIterator() [2/3]

template<typename TInteger >
DGtal::IntegerSequenceIterator< TInteger >::IntegerSequenceIterator ( const IntegerSequenceIterator< TInteger > &  other)
default

Copy constructor.

Parameters
otherthe object to clone.

◆ IntegerSequenceIterator() [3/3]

template<typename TInteger >
DGtal::IntegerSequenceIterator< TInteger >::IntegerSequenceIterator ( IntegerSequenceIterator< TInteger > &&  other)
default

Move constructor.

Parameters
otherthe object to move.

Member Function Documentation

◆ advance()

template<typename TInteger >
void DGtal::IntegerSequenceIterator< TInteger >::advance ( std::ptrdiff_t  n)
inlineprivate

Advances the iterator. Required by boost::iterator_facade.

Parameters
nthe number of forward steps performed by the iterator.

Definition at line 124 of file IntegerSequenceIterator.h.

References DGtal::IntegerSequenceIterator< TInteger >::myNumber.

124 { myNumber += n; }
Integer myNumber
The current value of the interator.

◆ decrement()

template<typename TInteger >
void DGtal::IntegerSequenceIterator< TInteger >::decrement ( )
inlineprivate

Decrements the iterator. Required by boost::iterator_facade.

Definition at line 121 of file IntegerSequenceIterator.h.

References DGtal::IntegerSequenceIterator< TInteger >::myNumber.

121 { myNumber--; }
Integer myNumber
The current value of the interator.

◆ dereference()

template<typename TInteger >
Integer const& DGtal::IntegerSequenceIterator< TInteger >::dereference ( ) const
inlineprivate
Returns
the integer value corresponding to the position of this iterator. Required by boost::iterator_facade.

Definition at line 135 of file IntegerSequenceIterator.h.

References DGtal::IntegerSequenceIterator< TInteger >::myNumber.

135 { return myNumber; }
Integer myNumber
The current value of the interator.

◆ distance_to()

template<typename TInteger >
std::ptrdiff_t DGtal::IntegerSequenceIterator< TInteger >::distance_to ( IntegerSequenceIterator< TInteger > const &  other)
inlineprivate

Distance to given iterator. Required by boost::iterator_facade.

Parameters
otherany iterator on the same sequence.

Definition at line 127 of file IntegerSequenceIterator.h.

References DGtal::IntegerSequenceIterator< TInteger >::myNumber.

128  { return other.myNumber - myNumber; }
Integer myNumber
The current value of the interator.

◆ equal()

template<typename TInteger >
bool DGtal::IntegerSequenceIterator< TInteger >::equal ( IntegerSequenceIterator< TInteger > const &  other) const
inlineprivate

Equality comparison with another iterator. Required by boost::iterator_facade.

Parameters
otherany iterator on the same sequence.

Definition at line 131 of file IntegerSequenceIterator.h.

References DGtal::IntegerSequenceIterator< TInteger >::myNumber.

132  { return this->myNumber == other.myNumber; }
Integer myNumber
The current value of the interator.

◆ increment()

template<typename TInteger >
void DGtal::IntegerSequenceIterator< TInteger >::increment ( )
inlineprivate

Increments the iterator. Required by boost::iterator_facade.

Definition at line 119 of file IntegerSequenceIterator.h.

References DGtal::IntegerSequenceIterator< TInteger >::myNumber.

119 { myNumber++; }
Integer myNumber
The current value of the interator.

◆ operator=() [1/2]

template<typename TInteger >
IntegerSequenceIterator& DGtal::IntegerSequenceIterator< TInteger >::operator= ( const IntegerSequenceIterator< TInteger > &  other)
default

Copy assignment operator.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.

◆ operator=() [2/2]

template<typename TInteger >
IntegerSequenceIterator& DGtal::IntegerSequenceIterator< TInteger >::operator= ( IntegerSequenceIterator< TInteger > &&  other)
default

Move assignment operator.

Parameters
otherthe object to move.
Returns
a reference on 'this'.

Friends And Related Function Documentation

◆ boost::iterator_core_access

template<typename TInteger >
friend class boost::iterator_core_access
friend

Definition at line 116 of file IntegerSequenceIterator.h.

Field Documentation

◆ myNumber

template<typename TInteger >
Integer DGtal::IntegerSequenceIterator< TInteger >::myNumber
protected

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