DGtal  0.9.3beta
Public Types | Public Member Functions | Private Member Functions | Private Attributes
DGtal::SimpleConstRange< TConstIterator > Class Template Reference

#include <DGtal/base/SimpleConstRange.h>

Public Types

typedef TConstIterator ConstIterator
 
typedef std::reverse_iterator< ConstIteratorConstReverseIterator
 
typedef Circulator< ConstIteratorConstCirculator
 
typedef std::reverse_iterator< ConstCirculatorConstReverseCirculator
 

Public Member Functions

 SimpleConstRange (const TConstIterator &itb, const TConstIterator &ite)
 
 SimpleConstRange (const SimpleConstRange &other)
 
SimpleConstRangeoperator= (const SimpleConstRange &other)
 
 ~SimpleConstRange ()
 
bool isValid () const
 
void selfDisplay (std::ostream &out) const
 
std::string className () const
 
ConstIterator begin () const
 
ConstIterator end () const
 
ConstReverseIterator rbegin () const
 
ConstReverseIterator rend () const
 
ConstCirculator c () const
 
ConstReverseCirculator rc () const
 

Private Member Functions

 BOOST_CONCEPT_ASSERT ((boost::BidirectionalIterator< TConstIterator >))
 

Private Attributes

TConstIterator myBegin
 
TConstIterator myEnd
 

Detailed Description

template<typename TConstIterator>
class DGtal::SimpleConstRange< TConstIterator >

Aim: model of CConstRange that adapts any range of elements bounded by two iterators [itb, ite) and provides services to (circularly)iterate over it (in a read-only manner).

Template Parameters
TConstIteratorthe type of the iterator to adapt (at least bidirectional)
See also
ConstRangeAdapter

Definition at line 72 of file SimpleConstRange.h.

Member Typedef Documentation

template<typename TConstIterator >
typedef Circulator<ConstIterator> DGtal::SimpleConstRange< TConstIterator >::ConstCirculator

Definition at line 83 of file SimpleConstRange.h.

template<typename TConstIterator >
typedef TConstIterator DGtal::SimpleConstRange< TConstIterator >::ConstIterator

Definition at line 80 of file SimpleConstRange.h.

template<typename TConstIterator >
typedef std::reverse_iterator<ConstCirculator> DGtal::SimpleConstRange< TConstIterator >::ConstReverseCirculator

Definition at line 84 of file SimpleConstRange.h.

template<typename TConstIterator >
typedef std::reverse_iterator<ConstIterator> DGtal::SimpleConstRange< TConstIterator >::ConstReverseIterator

Definition at line 81 of file SimpleConstRange.h.

Constructor & Destructor Documentation

template<typename TConstIterator >
DGtal::SimpleConstRange< TConstIterator >::SimpleConstRange ( const TConstIterator &  itb,
const TConstIterator &  ite 
)
inline

Standard constructor from two iterators and one functor.

Parameters
itbbegin iterator.
iteend iterator.

Definition at line 95 of file SimpleConstRange.h.

96  : myBegin(itb), myEnd(ite) {}
template<typename TConstIterator >
DGtal::SimpleConstRange< TConstIterator >::SimpleConstRange ( const SimpleConstRange< TConstIterator > &  other)
inline

Copy constructor.

Parameters
otherthe iterator to clone.

Definition at line 102 of file SimpleConstRange.h.

103  : myBegin(other.myBegin), myEnd(other.myEnd) {}
template<typename TConstIterator >
DGtal::SimpleConstRange< TConstIterator >::~SimpleConstRange ( )
inline

Destructor. Does nothing.

Definition at line 123 of file SimpleConstRange.h.

123 {}

Member Function Documentation

template<typename TConstIterator >
ConstIterator DGtal::SimpleConstRange< TConstIterator >::begin ( ) const
inline

Iterator service.

Returns
begin iterator

Definition at line 172 of file SimpleConstRange.h.

Referenced by DGtal::SimpleConstRange< TConstIterator >::c(), and DGtal::SimpleConstRange< TConstIterator >::rend().

172  {
173  return ConstIterator( myBegin );
174  }
TConstIterator ConstIterator
template<typename TConstIterator >
DGtal::SimpleConstRange< TConstIterator >::BOOST_CONCEPT_ASSERT ( (boost::BidirectionalIterator< TConstIterator >)  )
private
template<typename TConstIterator >
ConstCirculator DGtal::SimpleConstRange< TConstIterator >::c ( ) const
inline

Circulator service.

Returns
a circulator

Definition at line 204 of file SimpleConstRange.h.

References DGtal::SimpleConstRange< TConstIterator >::begin(), and DGtal::SimpleConstRange< TConstIterator >::end().

Referenced by DGtal::SimpleConstRange< TConstIterator >::rc().

204  {
205  return ConstCirculator( this->begin(), this->begin(), this->end() );
206  }
Circulator< ConstIterator > ConstCirculator
ConstIterator begin() const
ConstIterator end() const
template<typename TConstIterator >
std::string DGtal::SimpleConstRange< TConstIterator >::className ( ) const
inline
Returns
the style name used for drawing this object.

Definition at line 148 of file SimpleConstRange.h.

149  {
150  return "SimpleConstRange";
151  }
template<typename TConstIterator >
ConstIterator DGtal::SimpleConstRange< TConstIterator >::end ( ) const
inline

Iterator service.

Returns
end iterator

Definition at line 180 of file SimpleConstRange.h.

Referenced by DGtal::SimpleConstRange< TConstIterator >::c(), and DGtal::SimpleConstRange< TConstIterator >::rbegin().

180  {
181  return ConstIterator( myEnd );
182  }
TConstIterator ConstIterator
template<typename TConstIterator >
bool DGtal::SimpleConstRange< TConstIterator >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Definition at line 129 of file SimpleConstRange.h.

129 { return true; }
template<typename TConstIterator >
SimpleConstRange& DGtal::SimpleConstRange< TConstIterator >::operator= ( const SimpleConstRange< TConstIterator > &  other)
inline

Assignment.

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

Definition at line 110 of file SimpleConstRange.h.

References DGtal::SimpleConstRange< TConstIterator >::myBegin, and DGtal::SimpleConstRange< TConstIterator >::myEnd.

111  {
112  if ( this != &other )
113  {
114  myBegin = other.myBegin;
115  myEnd = other.myEnd;
116  }
117  return *this;
118  }
template<typename TConstIterator >
ConstReverseIterator DGtal::SimpleConstRange< TConstIterator >::rbegin ( ) const
inline

Iterator service.

Returns
rbegin iterator

Definition at line 188 of file SimpleConstRange.h.

References DGtal::SimpleConstRange< TConstIterator >::end().

188  {
189  return ConstReverseIterator(this->end());
190  }
std::reverse_iterator< ConstIterator > ConstReverseIterator
ConstIterator end() const
template<typename TConstIterator >
ConstReverseCirculator DGtal::SimpleConstRange< TConstIterator >::rc ( ) const
inline

Circulator service.

Returns
a reverse circulator

Definition at line 212 of file SimpleConstRange.h.

References DGtal::SimpleConstRange< TConstIterator >::c().

212  {
213  return ConstReverseCirculator( this->c() );
214  }
ConstCirculator c() const
std::reverse_iterator< ConstCirculator > ConstReverseCirculator
template<typename TConstIterator >
ConstReverseIterator DGtal::SimpleConstRange< TConstIterator >::rend ( ) const
inline

Iterator service.

Returns
rend iterator

Definition at line 196 of file SimpleConstRange.h.

References DGtal::SimpleConstRange< TConstIterator >::begin().

196  {
197  return ConstReverseIterator(this->begin());
198  }
ConstIterator begin() const
std::reverse_iterator< ConstIterator > ConstReverseIterator
template<typename TConstIterator >
void DGtal::SimpleConstRange< TConstIterator >::selfDisplay ( std::ostream &  out) const
inline

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

Definition at line 136 of file SimpleConstRange.h.

References DGtal::SimpleConstRange< TConstIterator >::myBegin, and DGtal::SimpleConstRange< TConstIterator >::myEnd.

137  {
138  typedef typename IteratorCirculatorTraits<ConstIterator>::Value Value;
139  out << "[SimpleConstRange]" << std::endl;
140  out << "\t";
141  std::copy( myBegin, myEnd, std::ostream_iterator<Value>(out, ", ") );
142  out << std::endl;
143  }

Field Documentation

template<typename TConstIterator >
TConstIterator DGtal::SimpleConstRange< TConstIterator >::myBegin
private
template<typename TConstIterator >
TConstIterator DGtal::SimpleConstRange< TConstIterator >::myEnd
private

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