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::IndexedListWithBlocks< TValue, N, M >::ConstIterator Class Reference

#include <IndexedListWithBlocks.h>

Collaboration diagram for DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator:
Collaboration graph
[legend]

Public Types

typedef ConstIterator Self
typedef TValue 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

 ~ConstIterator ()
 ConstIterator ()
 ConstIterator (const ConstIterator &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

 ConstIterator (const FirstBlock &block, unsigned int idx)

Protected Attributes

unsigned int myIdx
unsigned int myNbValues
const ValuemyValues
const AnyBlockmyNext

Friends

class IndexedListWithBlocks

Detailed Description

template<typename TValue, unsigned int N, unsigned int M>
class DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator

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

Definition at line 452 of file IndexedListWithBlocks.h.


Member Typedef Documentation

template<typename TValue, unsigned int N, unsigned int M>
typedef DifferenceType DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::difference_type

Definition at line 463 of file IndexedListWithBlocks.h.

template<typename TValue, unsigned int N, unsigned int M>
typedef std::ptrdiff_t DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::DifferenceType

Definition at line 458 of file IndexedListWithBlocks.h.

template<typename TValue, unsigned int N, unsigned int M>
typedef std::forward_iterator_tag DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::iterator_category

Definition at line 467 of file IndexedListWithBlocks.h.

template<typename TValue, unsigned int N, unsigned int M>
typedef const Value* DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::Pointer

Definition at line 456 of file IndexedListWithBlocks.h.

template<typename TValue, unsigned int N, unsigned int M>
typedef Pointer DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::pointer

Definition at line 464 of file IndexedListWithBlocks.h.

template<typename TValue, unsigned int N, unsigned int M>
typedef const Value& DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::Reference

Definition at line 457 of file IndexedListWithBlocks.h.

template<typename TValue, unsigned int N, unsigned int M>
typedef Reference DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::reference

Definition at line 465 of file IndexedListWithBlocks.h.

template<typename TValue, unsigned int N, unsigned int M>
typedef ConstIterator DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::Self

Definition at line 454 of file IndexedListWithBlocks.h.

template<typename TValue, unsigned int N, unsigned int M>
typedef std::size_t DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::size_type

Definition at line 462 of file IndexedListWithBlocks.h.

template<typename TValue, unsigned int N, unsigned int M>
typedef TValue DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::Value

Definition at line 455 of file IndexedListWithBlocks.h.

template<typename TValue, unsigned int N, unsigned int M>
typedef Value DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::value_type

Definition at line 461 of file IndexedListWithBlocks.h.


Constructor & Destructor Documentation

template<typename TValue , unsigned int N, unsigned int M>
DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::ConstIterator ( const FirstBlock block,
unsigned int  idx 
)
protected

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

Definition at line 249 of file IndexedListWithBlocks.ih.

References DGtal::IndexedListWithBlocks< TValue, N, M >::FirstBlock::data, DGtal::IndexedListWithBlocks< TValue, N, M >::ValueOrBlockPointer::nextBlock, DGtal::IndexedListWithBlocks< TValue, N, M >::FirstBlock::size, and DGtal::IndexedListWithBlocks< TValue, N, M >::FirstBlock::values.

{
ASSERT( idx <= block.size );
if ( block.size <= N+1 )
{
if ( idx <= N )
{
myIdx = idx;
myNbValues = N + 1;
myValues = block.values;
myNext = 0;
}
else
{ // end iterator.
myIdx = 0;
myValues = 0;
myNext = 0;
}
}
else
{
ASSERT( block.data.nextBlock != 0 );
myNext = block.data.nextBlock;
if ( idx < N )
{
myIdx = idx;
myValues = block.values;
}
else
{
idx -= N;
while ( idx >= M )
{
idx -= M;
myNext = ( myNext != 0 ) ? myNext->next : 0;
}
if ( myNext == 0 )
{
myIdx = 0;
myValues = 0;
}
else
{
myIdx = idx;
}
}
}
}
template<typename TValue , unsigned int N, unsigned int M>
DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::~ConstIterator ( )

Default destructor.

Definition at line 231 of file IndexedListWithBlocks.ih.

{}
template<typename TValue , unsigned int N, unsigned int M>
DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::ConstIterator ( )

Default constructor.

Definition at line 236 of file IndexedListWithBlocks.ih.

: myIdx( 0 ), myValues( 0 )
{}
template<typename TValue , unsigned int N, unsigned int M>
DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::ConstIterator ( const ConstIterator other)

Copy constructor.

Parameters:
otherthe object to clone.

Definition at line 242 of file IndexedListWithBlocks.ih.

: myIdx( other.myIdx ), myNbValues( other.myNbValues ),
myValues( other.myValues ), myNext( other.myNext )
{}

Member Function Documentation

template<typename TValue , unsigned int N, unsigned int M>
bool DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::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 IndexedListWithBlocks.ih.

References DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::myIdx, and DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::myValues.

{
return ( myValues != other.myValues ) || ( myIdx != other.myIdx );
}
template<typename TValue , unsigned int N, unsigned int M>
DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::Reference DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::operator* ( ) const
inline

Dereference operator.

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

Definition at line 323 of file IndexedListWithBlocks.ih.

{
ASSERT( myValues != 0 );
return myValues[ myIdx ];
}
template<typename TValue , unsigned int N, unsigned int M>
DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::Self & DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::operator++ ( )
inline

Pre-increment operator.

Returns:
a reference to itself.

Definition at line 343 of file IndexedListWithBlocks.ih.

{
return this->operator+=( 1 );
}
template<typename TValue , unsigned int N, unsigned int M>
DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::Self DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::operator++ ( int  )
inline

Post-increment operator.

Returns:
a reference to itself.

Definition at line 352 of file IndexedListWithBlocks.ih.

{
Self tmp( *this );
this->operator++();
return tmp;
}
template<typename TValue , unsigned int N, unsigned int M>
DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::Self & DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::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 IndexedListWithBlocks.ih.

{
myIdx += n;
while ( myIdx >= myNbValues )
{
if ( myNext == 0 )
{
myValues = 0;
myIdx = 0;
break;
}
}
return *this;
}
template<typename TValue , unsigned int N, unsigned int M>
DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::Pointer DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::operator-> ( ) const
inline

Pointer dereference operator.

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

Definition at line 333 of file IndexedListWithBlocks.ih.

{
ASSERT( myValues != 0 );
return myValues + myIdx;
}
template<typename TValue , unsigned int N, unsigned int M>
DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::Self & DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::operator= ( const Self other)
inline

Assignment.

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

Definition at line 307 of file IndexedListWithBlocks.ih.

References DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::myIdx, DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::myNbValues, DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::myNext, and DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::myValues.

{
if ( this != &other )
{
myIdx = other.myIdx;
myNbValues = other.myNbValues;
myValues = other.myValues;
myNext = other.myNext;
}
return *this;
}
template<typename TValue , unsigned int N, unsigned int M>
bool DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::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 IndexedListWithBlocks.ih.

References DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::myIdx, and DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::myValues.

{
return ( myValues == other.myValues ) && ( myIdx == other.myIdx );
}
template<typename TValue , unsigned int N, unsigned int M>
DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::Reference DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::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 IndexedListWithBlocks.ih.

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

Friends And Related Function Documentation

template<typename TValue, unsigned int N, unsigned int M>
friend class IndexedListWithBlocks
friend

Definition at line 476 of file IndexedListWithBlocks.h.


Field Documentation

template<typename TValue, unsigned int N, unsigned int M>
unsigned int DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::myIdx
protected
template<typename TValue, unsigned int N, unsigned int M>
unsigned int DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::myNbValues
protected
template<typename TValue, unsigned int N, unsigned int M>
const AnyBlock* DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::myNext
protected
template<typename TValue, unsigned int N, unsigned int M>
const Value* DGtal::IndexedListWithBlocks< TValue, N, M >::ConstIterator::myValues
protected

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