claw::graph< S, A, Comp >::graph_edge_iterator Class Reference

Iterator on the graph's edges. More...

#include <graph.hpp>

List of all members.

Classes

class  edge
 Value pointed by the iterator. More...

Public Types

typedef const edge value_type
typedef const edgereference
typedef const edge *const pointer
typedef ptrdiff_t difference_type
typedef
std::bidirectional_iterator_tag 
iterator_category

Public Member Functions

 graph_edge_iterator ()
 Constructor of the graph_edge_iterator class.
graph_edge_iteratoroperator++ ()
 Preincrement.
graph_edge_iterator operator++ (int)
 Postincrement.
graph_edge_iteratoroperator-- ()
 Predecrement.
graph_edge_iterator operator-- (int)
 postdecrement.
reference operator* () const
 Reference.
pointer operator-> () const
 Pointer.
bool operator== (const graph_edge_iterator &it) const
 Equality.
bool operator!= (const graph_edge_iterator &it) const
 Difference.

Private Member Functions

 graph_edge_iterator (typename graph_content::const_iterator it_begin, typename graph_content::const_iterator it_end, typename graph_content::const_iterator it_s, typename neighbours_list::const_iterator it_d)
 Constructor with an iterator on graph class data.

Private Attributes

graph_content::const_iterator m_vertex_begin
 Iterator of the first node.
graph_content::const_iterator m_vertex_end
 Iterator of the last node.
graph_content::const_iterator m_vertex_iterator
 Iterator on the list of vertex.
neighbours_list::const_iterator m_neighbours_iterator
 Iterator on the list of edges.
edge m_edge
 Current edge.

Friends

class graph< vertex_type, edge_type, vertex_compare >

Detailed Description

template<class S, class A = meta::no_type, class Comp = std::less<S>>
class claw::graph< S, A, Comp >::graph_edge_iterator

Iterator on the graph's edges.

Definition at line 142 of file graph.hpp.


Member Typedef Documentation

template<class S, class A = meta::no_type, class Comp = std::less<S>>
typedef ptrdiff_t claw::graph< S, A, Comp >::graph_edge_iterator::difference_type

Definition at line 175 of file graph.hpp.

template<class S, class A = meta::no_type, class Comp = std::less<S>>
typedef std::bidirectional_iterator_tag claw::graph< S, A, Comp >::graph_edge_iterator::iterator_category

Definition at line 177 of file graph.hpp.

template<class S, class A = meta::no_type, class Comp = std::less<S>>
typedef const edge* const claw::graph< S, A, Comp >::graph_edge_iterator::pointer

Definition at line 174 of file graph.hpp.

template<class S, class A = meta::no_type, class Comp = std::less<S>>
typedef const edge& claw::graph< S, A, Comp >::graph_edge_iterator::reference

Definition at line 173 of file graph.hpp.

template<class S, class A = meta::no_type, class Comp = std::less<S>>
typedef const edge claw::graph< S, A, Comp >::graph_edge_iterator::value_type

Definition at line 172 of file graph.hpp.


Constructor & Destructor Documentation

template<class S , class A , class Comp >
claw::graph< S, A, Comp >::graph_edge_iterator::graph_edge_iterator (  )  [inline]

Constructor of the graph_edge_iterator class.

Definition at line 275 of file graph.tpp.

00276 {
00277 
00278 } // graph_edge_iterator() [constructor]

template<class S , class A , class Comp >
claw::graph< S, A, Comp >::graph_edge_iterator::graph_edge_iterator ( typename graph_content::const_iterator  it_begin,
typename graph_content::const_iterator  it_end,
typename graph_content::const_iterator  it_s,
typename neighbours_list::const_iterator  it_d 
) [inline, explicit, private]

Constructor with an iterator on graph class data.

Parameters:
it_begin Iterator on the first node.
it_end Iterator on the last node.
it_s Iterator on current edge's source.
it_d Iterator where scan starts.

Definition at line 464 of file graph.tpp.

References claw::graph< S, A, Comp >::graph_edge_iterator::edge::set().

00468   : m_vertex_begin(it_begin), m_vertex_end(it_end), 
00469     m_vertex_iterator(it_s), m_neighbours_iterator(it_d)
00470 {
00471   if (m_vertex_begin != m_vertex_end)
00472     m_edge.set( m_neighbours_iterator->second, m_vertex_iterator->first,
00473                 m_neighbours_iterator->first );
00474 } // graph_edge_iterator() [constructor on an iterator]


Member Function Documentation

template<class S , class A , class Comp >
bool claw::graph< S, A, Comp >::graph_edge_iterator::operator!= ( const graph_edge_iterator it  )  const [inline]

Difference.

Parameters:
it Iterator to compare to.
Precondition:
Iterator and it are not at the end of their respective containers.

Definition at line 449 of file graph.tpp.

00450 {
00451   return !(*this == it);
00452 } // operator!=()

template<class S , class A , class Comp >
claw::graph< S, A, Comp >::graph_edge_iterator::reference claw::graph< S, A, Comp >::graph_edge_iterator::operator* (  )  const [inline]

Reference.

Precondition:
Iterator is not at the end of the container.

Definition at line 395 of file graph.tpp.

References claw::graph< S, A, Comp >::graph_edge_iterator::m_edge.

00396 {
00397   return m_edge;
00398 } // operator*()

template<class S , class A , class Comp >
claw::graph< S, A, Comp >::graph_edge_iterator claw::graph< S, A, Comp >::graph_edge_iterator::operator++ ( int   )  [inline]

Postincrement.

Precondition:
Iterator is not at the end of the container.

Definition at line 323 of file graph.tpp.

00324 {
00325   graph_edge_iterator it_tmp(*this);
00326   ++(*this);
00327   return it_tmp;
00328 } // operator++() [postincrement]

template<class S , class A , class Comp >
claw::graph< S, A, Comp >::graph_edge_iterator & claw::graph< S, A, Comp >::graph_edge_iterator::operator++ (  )  [inline]

Preincrement.

Precondition:
Iterator is not at the end of the container.

Definition at line 287 of file graph.tpp.

References claw::graph< S, A, Comp >::graph_edge_iterator::m_edge, claw::graph< S, A, Comp >::graph_edge_iterator::m_neighbours_iterator, claw::graph< S, A, Comp >::graph_edge_iterator::m_vertex_end, claw::graph< S, A, Comp >::graph_edge_iterator::m_vertex_iterator, and claw::graph< S, A, Comp >::graph_edge_iterator::edge::set().

00288 {
00289   bool ok = true;
00290   ++m_neighbours_iterator;
00291 
00292   // end of a neighbourhood
00293   if ( m_neighbours_iterator == m_vertex_iterator->second.end() )
00294     {
00295       // find next edge or end.
00296       ok = false;
00297       ++m_vertex_iterator;
00298 
00299       while ( (m_vertex_iterator != m_vertex_end) && !ok )
00300         if ( !m_vertex_iterator->second.empty() )
00301           {
00302             ok = true;
00303             m_neighbours_iterator = m_vertex_iterator->second.begin();
00304           }
00305         else
00306           ++m_vertex_iterator;
00307     }
00308 
00309   if (ok)
00310     m_edge.set( m_neighbours_iterator->second, m_vertex_iterator->first,
00311                 m_neighbours_iterator->first );
00312 
00313   return *this;
00314 } // operator++() [preincrement]

template<class S , class A , class Comp >
claw::graph< S, A, Comp >::graph_edge_iterator claw::graph< S, A, Comp >::graph_edge_iterator::operator-- ( int   )  [inline]

postdecrement.

Precondition:
Iterator is not at the begining of the container.

Definition at line 381 of file graph.tpp.

00382 {
00383   graph_edge_iterator it_tmp(*this);
00384   --(*this);
00385   return it_tmp;
00386 } // operator--() [postdecrement]

template<class S , class A , class Comp >
claw::graph< S, A, Comp >::graph_edge_iterator & claw::graph< S, A, Comp >::graph_edge_iterator::operator-- (  )  [inline]

Predecrement.

Precondition:
Iterator is not at the begining of the container.

Definition at line 337 of file graph.tpp.

References claw::graph< S, A, Comp >::graph_edge_iterator::m_edge, claw::graph< S, A, Comp >::graph_edge_iterator::m_neighbours_iterator, claw::graph< S, A, Comp >::graph_edge_iterator::m_vertex_begin, claw::graph< S, A, Comp >::graph_edge_iterator::m_vertex_end, claw::graph< S, A, Comp >::graph_edge_iterator::m_vertex_iterator, and claw::graph< S, A, Comp >::graph_edge_iterator::edge::set().

00338 {
00339   bool ok = true;
00340 
00341   if (m_vertex_iterator == m_vertex_end)
00342     {
00343       --m_vertex_iterator;
00344       m_neighbours_iterator = m_vertex_iterator->second.end();
00345     }
00346 
00347   // begining of a neighbourhood
00348   if ( m_neighbours_iterator == m_vertex_iterator->second.begin() )
00349     {
00350       ok = false;
00351       // find previous edge or begining.
00352       while ( (m_vertex_iterator != m_vertex_begin) && !ok )
00353         {
00354           --m_vertex_iterator;
00355           if ( !m_vertex_iterator->second.empty() )
00356             {
00357               ok = true;
00358               m_neighbours_iterator = --m_vertex_iterator->second.end();
00359             }
00360         }
00361     }
00362   else
00363     --m_neighbours_iterator;
00364 
00365   if (!ok)
00366     m_vertex_iterator == m_vertex_end;
00367   else
00368     m_edge.set( m_neighbours_iterator->second, m_vertex_iterator->first,
00369                 m_neighbours_iterator->first );
00370 
00371   return *this;
00372 } // operator--() [predecrement]

template<class S , class A , class Comp >
claw::graph< S, A, Comp >::graph_edge_iterator::pointer claw::graph< S, A, Comp >::graph_edge_iterator::operator-> (  )  const [inline]

Pointer.

Precondition:
Iterator is not at the end of the container.

Definition at line 407 of file graph.tpp.

References claw::graph< S, A, Comp >::graph_edge_iterator::m_edge.

00408 {
00409   return &m_edge;
00410 } // operator->()

template<class S , class A , class Comp >
bool claw::graph< S, A, Comp >::graph_edge_iterator::operator== ( const graph_edge_iterator it  )  const [inline]

Equality.

Parameters:
it Iterator to compare to.
Precondition:
Iterator and it are not at the end of their respective containers.

Definition at line 420 of file graph.tpp.

00421 {
00422   // both are empty
00423   if ( m_vertex_begin == m_vertex_end )
00424     return (it.m_vertex_begin == it.m_vertex_end) 
00425       && (m_vertex_begin == it.m_vertex_begin);
00426   else
00427     if ( it.m_vertex_begin == it.m_vertex_end ) // -it- is empty
00428       return false;
00429     else
00430       // none is empty, perheaps at the end ?
00431       if (m_vertex_iterator == m_vertex_end)
00432         return (it.m_vertex_iterator == it.m_vertex_end)
00433           && (m_vertex_begin == it.m_vertex_begin);
00434       else
00435         if (it.m_vertex_iterator == it.m_vertex_end)
00436           return false;
00437         else
00438           return m_neighbours_iterator == it.m_neighbours_iterator;
00439 } // operator==()


Friends And Related Function Documentation

template<class S, class A = meta::no_type, class Comp = std::less<S>>
friend class graph< vertex_type, edge_type, vertex_compare > [friend]

Definition at line 144 of file graph.hpp.


Member Data Documentation

template<class S, class A = meta::no_type, class Comp = std::less<S>>
edge claw::graph< S, A, Comp >::graph_edge_iterator::m_edge [private]
template<class S, class A = meta::no_type, class Comp = std::less<S>>
neighbours_list::const_iterator claw::graph< S, A, Comp >::graph_edge_iterator::m_neighbours_iterator [private]
template<class S, class A = meta::no_type, class Comp = std::less<S>>
graph_content::const_iterator claw::graph< S, A, Comp >::graph_edge_iterator::m_vertex_begin [private]

Iterator of the first node.

Definition at line 200 of file graph.hpp.

Referenced by claw::graph< S, A, Comp >::graph_edge_iterator::operator--().

template<class S, class A = meta::no_type, class Comp = std::less<S>>
graph_content::const_iterator claw::graph< S, A, Comp >::graph_edge_iterator::m_vertex_end [private]
template<class S, class A = meta::no_type, class Comp = std::less<S>>
graph_content::const_iterator claw::graph< S, A, Comp >::graph_edge_iterator::m_vertex_iterator [private]

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

Generated on 9 Nov 2009 for CLAW Library (a C++ Library Absolutely Wonderful) by  doxygen 1.6.1