DGtal 1.3.0
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends
boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator Class Reference

#include <DGtal/graph/DigitalSurfaceBoostGraphInterface.h>

Inheritance diagram for boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator:

Public Member Functions

 out_edge_iterator ()
 out_edge_iterator (typename OutEdgeContainer::const_iterator it, const DGtal::CountedPtr< OutEdgeContainer > &out_edges)

Private Member Functions

const Arcdereference () const
bool equal (const out_edge_iterator &other) const
void increment ()
void decrement ()

Private Attributes

OutEdgeContainer::const_iterator myIterator
 The iterator pointing in the container of out edges. More...
DGtal::CountedPtr< OutEdgeContainermyOutEdges


class iterator_core_access

Detailed Description

template<class TDigitalSurfaceContainer>
class boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator

Iterator for visiting out edges. We use an iterator facade to create a STL-compliant iterator with as little effort as possible.

The difficulty is that DGtal graphs do not provide iterators for visiting edges or adjacent vertices, but merely provide a method that outputs them. Therefore, this iterator shares the container of out edges (a std::vector) with other (potentially) iterators, through a DGtal::CountedPtr. When the last iterator pointing in this structure is desallocated, the container is automatically desallocated. This is for instance used by function out_edges, which returns a pair of out_edge_iterator, both points on the same container. Another problem is that the user may have called twice out_edges on the same vertex, and may wish to compare iterators obtained by two different calls..
typedef typename DigitalSurface<...> G;
typedef typename graph_traits<G>::out_edge_iterator out_edge_iterator;
G g(...);
std::pair<out_edge_iterator,out_edge_iterator> vp1 = boost::out_edges( vertex, g );
std::pair<out_edge_iterator,out_edge_iterator> vp2 = boost::out_edges( vertex, g );
std::pair< typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator, typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator > out_edges(typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_descriptor u, const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)

In this case, vp1 and vp2 are not pointing on the same structure, hence the address pointed by vp1 is different from the address pointed by vp2. They are then not comparable a priori. The out_edge_iterator is written so that vp1 (.first or .second) and vp2 (.first or .second) are comparable, using value comparison and out-of-range check.

Definition at line 251 of file DigitalSurfaceBoostGraphInterface.h.

Constructor & Destructor Documentation

◆ out_edge_iterator() [1/2]

template<class TDigitalSurfaceContainer >
boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator::out_edge_iterator ( )

◆ out_edge_iterator() [2/2]

template<class TDigitalSurfaceContainer >
boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator::out_edge_iterator ( typename OutEdgeContainer::const_iterator  it,
const DGtal::CountedPtr< OutEdgeContainer > &  out_edges 

Definition at line 262 of file DigitalSurfaceBoostGraphInterface.h.

264 : myIterator( it ), myOutEdges( out_edges ) {}

References boost::out_edges().

Member Function Documentation

◆ decrement()

template<class TDigitalSurfaceContainer >
void boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator::decrement ( )

Definition at line 285 of file DigitalSurfaceBoostGraphInterface.h.

285{ --myIterator; }

◆ dereference()

template<class TDigitalSurfaceContainer >
const Arc & boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator::dereference ( ) const

Definition at line 267 of file DigitalSurfaceBoostGraphInterface.h.

268 {
269 ASSERT( myIterator != myOutEdges->end() );
270 return *myIterator;
271 }

◆ equal()

template<class TDigitalSurfaceContainer >
bool boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator::equal ( const out_edge_iterator &  other) const

Definition at line 274 of file DigitalSurfaceBoostGraphInterface.h.

275 {
276 bool thisAtEnd = ( myIterator == myOutEdges->end() );
277 bool otherAtEnd = ( other.myIterator == other.myOutEdges->end() );
278 if ( thisAtEnd || otherAtEnd ) return thisAtEnd && otherAtEnd;
279 else return *myIterator == *other.myIterator;
280 }

◆ increment()

template<class TDigitalSurfaceContainer >
void boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator::increment ( )

Definition at line 283 of file DigitalSurfaceBoostGraphInterface.h.

283{ ++myIterator; }

Friends And Related Function Documentation

◆ iterator_core_access

template<class TDigitalSurfaceContainer >
friend class iterator_core_access

Definition at line 294 of file DigitalSurfaceBoostGraphInterface.h.

Field Documentation

◆ myIterator

template<class TDigitalSurfaceContainer >
OutEdgeContainer::const_iterator boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator::myIterator

The iterator pointing in the container of out edges.

Definition at line 288 of file DigitalSurfaceBoostGraphInterface.h.

◆ myOutEdges

template<class TDigitalSurfaceContainer >
DGtal::CountedPtr< OutEdgeContainer > boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator::myOutEdges

A counted pointer to the dynamically allocated container of out edges. Will be automatically deallocated when there is no more iterators pointing on it.

Definition at line 292 of file DigitalSurfaceBoostGraphInterface.h.

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