DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends
DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator Class Reference

#include <LabelledMap.h>

Collaboration diagram for DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator:
Collaboration graph
[legend]

Public Types

typedef BlockConstIterator Self
typedef TData Value
typedef const ValuePointer
typedef const ValueReference
typedef std::ptrdiff_t DifferenceType
typedef Value value_type
typedef std::size_t size_type
typedef DifferenceType difference_type
typedef Pointer pointer
typedef Reference reference
typedef std::forward_iterator_tag iterator_category

Public Member Functions

 ~BlockConstIterator ()
 BlockConstIterator ()
 BlockConstIterator (const BlockConstIterator &other)
Selfoperator= (const Self &other)
Reference operator* () const
Pointer operator-> () const
Selfoperator++ ()
Self operator++ (int)
Selfoperator+= (DifferenceType n)
Reference operator[] (DifferenceType n) const
bool operator== (const Self &other) const
bool operator!= (const Self &other) const

Protected Member Functions

 BlockConstIterator (const __FirstBlock &block, unsigned int idx, unsigned int size)

Protected Attributes

unsigned int myIdx
unsigned int myNbDatas
const DatamyDatas
const __AnyBlockmyNext

Friends

class LabelledMap

Detailed Description

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
class DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator

Pseudo-random iterator to visit LabelledMap (it is only a random forward iterator). Model of boost::ForwardIterator. Provides also + and += arithmetic.

Definition at line 511 of file LabelledMap.h.


Member Typedef Documentation

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef DifferenceType DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::difference_type

Definition at line 522 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef std::ptrdiff_t DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::DifferenceType

Definition at line 517 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef std::forward_iterator_tag DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::iterator_category

Definition at line 526 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef const Value* DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::Pointer

Definition at line 515 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef Pointer DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::pointer

Definition at line 523 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef const Value& DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::Reference

Definition at line 516 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef Reference DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::reference

Definition at line 524 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef BlockConstIterator DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::Self

Definition at line 513 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef std::size_t DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::size_type

Definition at line 521 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef TData DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::Value

Definition at line 514 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef Value DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::value_type

Definition at line 520 of file LabelledMap.h.


Constructor & Destructor Documentation

template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::BlockConstIterator ( const __FirstBlock block,
unsigned int  idx,
unsigned int  size 
)
protected

Constructor from first block and index. Used by class LabelledMap.

Definition at line 249 of file LabelledMap.ih.

References DGtal::LabelledMap< TData, L, TWord, N, M >::__FirstBlock::data, DGtal::LabelledMap< TData, L, TWord, N, M >::__FirstBlock::datas, and DGtal::LabelledMap< TData, L, TWord, N, M >::DataOrBlockPointer::nextBlock.

{
ASSERT( idx <= size );
if ( size <= N+1 )
{
if ( idx <= N )
{
myIdx = idx;
myNbDatas = N + 1;
myDatas = block.datas;
myNext = 0;
}
else
{ // end iterator.
myIdx = 0;
myNbDatas = 0;
myDatas = 0;
myNext = 0;
}
}
else
{
ASSERT( block.data.nextBlock != 0 );
myNext = block.data.nextBlock;
if ( idx < N )
{
myIdx = idx;
myNbDatas = N;
myDatas = block.datas;
}
else
{
idx -= N;
while ( idx >= M )
{
idx -= M;
myNext = ( myNext != 0 ) ? myNext->next : 0;
}
if ( myNext == 0 )
{
myIdx = 0;
myNbDatas = 0;
myDatas = 0;
}
else
{
myIdx = idx;
myNbDatas = M;
}
}
}
}
template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::~BlockConstIterator ( )

Default destructor.

Definition at line 231 of file LabelledMap.ih.

{}
template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::BlockConstIterator ( )

Default constructor.

Definition at line 236 of file LabelledMap.ih.

: myIdx( 0 ), myDatas( 0 )
{}
template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::BlockConstIterator ( const BlockConstIterator other)

Copy constructor.

Parameters:
otherthe object to clone.

Definition at line 242 of file LabelledMap.ih.

: myIdx( other.myIdx ), myNbDatas( other.myNbDatas ),
myDatas( other.myDatas ), myNext( other.myNext )
{}

Member Function Documentation

template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
bool DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::operator!= ( const Self other) const
inline

Inequality operator.

Parameters:
otherany other iterator.
Returns:
'true' iff the iterators points on different elements.

Definition at line 372 of file LabelledMap.ih.

References DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::myDatas, and DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::myIdx.

{
return ( myDatas != other.myDatas ) || ( myIdx != other.myIdx );
}
template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::Reference DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::operator* ( ) const
inline

Dereference operator.

Returns:
the current data of the iterator, if valid.

Definition at line 323 of file LabelledMap.ih.

{
ASSERT( myDatas != 0 );
return myDatas[ myIdx ];
}
template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::Self & DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::operator++ ( )
inline

Pre-increment operator.

Returns:
a reference to itself.

Definition at line 343 of file LabelledMap.ih.

{
return this->operator+=( 1 );
}
template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::Self DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::operator++ ( int  )
inline

Post-increment operator.

Returns:
a reference to itself.

Definition at line 352 of file LabelledMap.ih.

{
Self tmp( *this );
this->operator++();
return tmp;
}
template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::Self & DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::operator+= ( DifferenceType  n)
inline

Addition operator. Moves the iterator at position + n.

Parameters:
nany positive integer
Returns:
a reference to itself.

Definition at line 381 of file LabelledMap.ih.

{
myIdx += n;
while ( myIdx >= myNbDatas )
{
if ( myNext == 0 )
{
myDatas = 0;
myIdx = 0;
break;
}
myNbDatas = M;
}
return *this;
}
template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::Pointer DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::operator-> ( ) const
inline

Pointer dereference operator.

Returns:
a non-mutable pointer on the current data.

Definition at line 333 of file LabelledMap.ih.

{
ASSERT( myDatas != 0 );
return myDatas + myIdx;
}
template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::Self & DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::operator= ( const Self other)
inline

Assignment.

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

Definition at line 307 of file LabelledMap.ih.

References DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::myDatas, DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::myIdx, DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::myNbDatas, and DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::myNext.

{
if ( this != &other )
{
myIdx = other.myIdx;
myNbDatas = other.myNbDatas;
myDatas = other.myDatas;
myNext = other.myNext;
}
return *this;
}
template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
bool DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::operator== ( const Self other) const
inline

Equality operator.

Parameters:
otherany other iterator.
Returns:
'true' iff the iterators points on the same element.

Definition at line 363 of file LabelledMap.ih.

References DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::myDatas, and DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::myIdx.

{
return ( myDatas == other.myDatas ) && ( myIdx == other.myIdx );
}
template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::Reference DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::operator[] ( DifferenceType  n) const
inline

Positive offset dereference operator. Moves the iterator at position + n.

Parameters:
nany positive integer
Returns:
a reference to itself.

Definition at line 404 of file LabelledMap.ih.

{
Self tmp( *this );
tmp += n;
return *tmp;
}

Friends And Related Function Documentation

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
friend class LabelledMap
friend

Definition at line 535 of file LabelledMap.h.


Field Documentation

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
const Data* DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::myDatas
protected
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
unsigned int DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::myIdx
protected
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
unsigned int DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::myNbDatas
protected
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
const __AnyBlock* DGtal::LabelledMap< TData, L, TWord, N, M >::BlockConstIterator::myNext
protected

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