DGtal  1.5.beta
DGtal::InputIteratorWithRankOnSequence< TSequence, TRank > Class Template Reference

Aim: Useful to create an iterator that returns a pair (value,rank) when visiting a sequence. The sequence is smartly copied within the iterator. Hence, the given sequence need not to persist during the visit. Since it is only an input sequence, it is not necessary to give a valid sequence when creating the end() iterator. More...

#include <DGtal/base/InputIteratorWithRankOnSequence.h>

Public Types

typedef TSequence Sequence
 
typedef TRank Rank
 
typedef InputIteratorWithRankOnSequence< Sequence, RankSelf
 
typedef Sequence::value_type SequenceValue
 
typedef std::pair< SequenceValue, RankValue
 
typedef Sequence::const_iterator ConstIterator
 
typedef ValuePointer
 
typedef Value value_type
 
typedef Sequence::size_type size_type
 
typedef Sequence::difference_type difference_type
 
typedef Pointer pointer
 
typedef value_typereference
 
typedef reference const_reference
 
typedef std::input_iterator_tag iterator_category
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((boost::Sequence< TSequence >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CInteger< TRank >))
 
 ~InputIteratorWithRankOnSequence ()
 
 InputIteratorWithRankOnSequence (const Sequence &seq, ConstIterator it)
 
 InputIteratorWithRankOnSequence (Sequence *ptrSeq, ConstIterator it)
 
 InputIteratorWithRankOnSequence (const CountedPtr< Sequence > &ptrSeq, ConstIterator it)
 
 InputIteratorWithRankOnSequence (const Self &other)
 
Selfoperator= (const Self &other)
 
Value operator* () const
 
Pointer operator-> () const
 
Selfoperator++ ()
 
Self operator++ (int)
 
bool operator== (const Self &other) const
 
bool operator!= (const Self &other) const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Protected Member Functions

 InputIteratorWithRankOnSequence ()
 

Private Attributes

CountedPtr< SequencemySequence
 A smart pointer to the visited sequence. More...
 
ConstIterator myIterator
 The current iterator position on the sequence. More...
 
Value myTmpValue
 

Detailed Description

template<typename TSequence, typename TRank = typename TSequence::difference_type>
class DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >

Aim: Useful to create an iterator that returns a pair (value,rank) when visiting a sequence. The sequence is smartly copied within the iterator. Hence, the given sequence need not to persist during the visit. Since it is only an input sequence, it is not necessary to give a valid sequence when creating the end() iterator.

Description of template class 'InputIteratorWithRankOnSequence'

It is used by SternBrocot::Fraction, LightSternBrocot::Fraction, LighterSternBrocot::Fraction to visit the quotients of the continued fraction.

It is a model of boost::InputIterator.

Note
It is not exactly an adapter since it requires the sequence itself. In fact, it could be decomposed into an adapter (which creates a pair) and a proxy on sequence.
Template Parameters
TSequencethe type of sequence (a model of Sequence).
TRankthe type of the rank (a model of CInteger).

Definition at line 79 of file InputIteratorWithRankOnSequence.h.

Member Typedef Documentation

◆ const_reference

template<typename TSequence , typename TRank = typename TSequence::difference_type>
typedef reference DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::const_reference

Definition at line 100 of file InputIteratorWithRankOnSequence.h.

◆ ConstIterator

template<typename TSequence , typename TRank = typename TSequence::difference_type>
typedef Sequence::const_iterator DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::ConstIterator

Definition at line 91 of file InputIteratorWithRankOnSequence.h.

◆ difference_type

template<typename TSequence , typename TRank = typename TSequence::difference_type>
typedef Sequence::difference_type DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::difference_type

Definition at line 97 of file InputIteratorWithRankOnSequence.h.

◆ iterator_category

template<typename TSequence , typename TRank = typename TSequence::difference_type>
typedef std::input_iterator_tag DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::iterator_category

Definition at line 101 of file InputIteratorWithRankOnSequence.h.

◆ Pointer

template<typename TSequence , typename TRank = typename TSequence::difference_type>
typedef Value* DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::Pointer

Definition at line 92 of file InputIteratorWithRankOnSequence.h.

◆ pointer

template<typename TSequence , typename TRank = typename TSequence::difference_type>
typedef Pointer DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::pointer

Definition at line 98 of file InputIteratorWithRankOnSequence.h.

◆ Rank

template<typename TSequence , typename TRank = typename TSequence::difference_type>
typedef TRank DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::Rank

Definition at line 87 of file InputIteratorWithRankOnSequence.h.

◆ reference

template<typename TSequence , typename TRank = typename TSequence::difference_type>
typedef value_type& DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::reference

Definition at line 99 of file InputIteratorWithRankOnSequence.h.

◆ Self

template<typename TSequence , typename TRank = typename TSequence::difference_type>
typedef InputIteratorWithRankOnSequence<Sequence,Rank> DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::Self

Definition at line 88 of file InputIteratorWithRankOnSequence.h.

◆ Sequence

template<typename TSequence , typename TRank = typename TSequence::difference_type>
typedef TSequence DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::Sequence

Definition at line 86 of file InputIteratorWithRankOnSequence.h.

◆ SequenceValue

template<typename TSequence , typename TRank = typename TSequence::difference_type>
typedef Sequence::value_type DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::SequenceValue

Definition at line 89 of file InputIteratorWithRankOnSequence.h.

◆ size_type

template<typename TSequence , typename TRank = typename TSequence::difference_type>
typedef Sequence::size_type DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::size_type

Definition at line 96 of file InputIteratorWithRankOnSequence.h.

◆ Value

template<typename TSequence , typename TRank = typename TSequence::difference_type>
typedef std::pair<SequenceValue,Rank> DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::Value

Definition at line 90 of file InputIteratorWithRankOnSequence.h.

◆ value_type

template<typename TSequence , typename TRank = typename TSequence::difference_type>
typedef Value DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::value_type

Definition at line 95 of file InputIteratorWithRankOnSequence.h.

Constructor & Destructor Documentation

◆ ~InputIteratorWithRankOnSequence()

template<typename TSequence , typename TRank = typename TSequence::difference_type>
DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::~InputIteratorWithRankOnSequence ( )

Destructor.

◆ InputIteratorWithRankOnSequence() [1/5]

template<typename TSequence , typename TRank = typename TSequence::difference_type>
DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::InputIteratorWithRankOnSequence ( const Sequence seq,
ConstIterator  it 
)

Constructor.

Parameters
seqany sequence.
itany iterator in the sequence seq.

◆ InputIteratorWithRankOnSequence() [2/5]

template<typename TSequence , typename TRank = typename TSequence::difference_type>
DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::InputIteratorWithRankOnSequence ( Sequence ptrSeq,
ConstIterator  it 
)

Constructor.

Parameters
ptrSeqany dynamically allocated pointer on a sequence (acquired).
itany iterator in the sequence ptrSeq.

◆ InputIteratorWithRankOnSequence() [3/5]

template<typename TSequence , typename TRank = typename TSequence::difference_type>
DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::InputIteratorWithRankOnSequence ( const CountedPtr< Sequence > &  ptrSeq,
ConstIterator  it 
)

Constructor.

Parameters
ptrSeqany smart pointer on a sequence (CountedPtr or CowPtr).
itany iterator in the sequence ptrSeq.

◆ InputIteratorWithRankOnSequence() [4/5]

template<typename TSequence , typename TRank = typename TSequence::difference_type>
DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::InputIteratorWithRankOnSequence ( const Self other)

Copy constructor.

Parameters
otherthe object to clone.

◆ InputIteratorWithRankOnSequence() [5/5]

template<typename TSequence , typename TRank = typename TSequence::difference_type>
DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::InputIteratorWithRankOnSequence ( )
protected

Constructor.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT() [1/2]

template<typename TSequence , typename TRank = typename TSequence::difference_type>
DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::BOOST_CONCEPT_ASSERT ( (boost::Sequence< TSequence >)  )

◆ BOOST_CONCEPT_ASSERT() [2/2]

template<typename TSequence , typename TRank = typename TSequence::difference_type>
DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::BOOST_CONCEPT_ASSERT ( (concepts::CInteger< TRank >)  )

◆ isValid()

template<typename TSequence , typename TRank = typename TSequence::difference_type>
bool DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

◆ operator!=()

template<typename TSequence , typename TRank = typename TSequence::difference_type>
bool DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::operator!= ( const Self other) const

Inequality operator.

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

◆ operator*()

template<typename TSequence , typename TRank = typename TSequence::difference_type>
Value DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::operator* ( ) const

Dereference operator.

Returns
the current value of the iterator, if valid.

◆ operator++() [1/2]

template<typename TSequence , typename TRank = typename TSequence::difference_type>
Self& DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::operator++ ( )

Pre-increment operator.

Returns
a reference to itself.

◆ operator++() [2/2]

template<typename TSequence , typename TRank = typename TSequence::difference_type>
Self DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::operator++ ( int  )

Post-increment operator.

Returns
a reference to itself.

◆ operator->()

template<typename TSequence , typename TRank = typename TSequence::difference_type>
Pointer DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::operator-> ( ) const

Pointer dereference operator.

Returns
a non-mutable pointer on the current value.

◆ operator=()

template<typename TSequence , typename TRank = typename TSequence::difference_type>
Self& DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::operator= ( const Self other)

Assignment.

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

◆ operator==()

template<typename TSequence , typename TRank = typename TSequence::difference_type>
bool DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::operator== ( const Self other) const

Equality operator.

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

◆ selfDisplay()

template<typename TSequence , typename TRank = typename TSequence::difference_type>
void DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

Field Documentation

◆ myIterator

template<typename TSequence , typename TRank = typename TSequence::difference_type>
ConstIterator DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::myIterator
private

The current iterator position on the sequence.

Definition at line 206 of file InputIteratorWithRankOnSequence.h.

◆ mySequence

template<typename TSequence , typename TRank = typename TSequence::difference_type>
CountedPtr<Sequence> DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::mySequence
private

A smart pointer to the visited sequence.

Definition at line 204 of file InputIteratorWithRankOnSequence.h.

◆ myTmpValue

template<typename TSequence , typename TRank = typename TSequence::difference_type>
Value DGtal::InputIteratorWithRankOnSequence< TSequence, TRank >::myTmpValue
private

Hack to store a value when using operator->. This value is not copied nor initialized.

Definition at line 209 of file InputIteratorWithRankOnSequence.h.


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