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

#include <graph.hpp>

List of all members.


Detailed Description

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

Iterator on the graph's edges.

Definition at line 149 of file graph.hpp.


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 >

Classes

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

Member Typedef Documentation

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

Definition at line 181 of file graph.hpp.

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

Definition at line 182 of file graph.hpp.

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

Definition at line 183 of file graph.hpp.

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

Definition at line 184 of file graph.hpp.

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

Definition at line 186 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 295 of file graph.tpp.

00296 {
00297 
00298 } // 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 490 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().

00494   : m_vertex_begin(it_begin), m_vertex_end(it_end), 
00495     m_vertex_iterator(it_s), m_neighbours_iterator(it_d)
00496 {
00497   if (m_vertex_begin != m_vertex_end)
00498     m_edge.set( m_neighbours_iterator->second, m_vertex_iterator->first,
00499                 m_neighbours_iterator->first );
00500 } // graph_edge_iterator() [constructor on an iterator]


Member Function Documentation

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 307 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().

00308 {
00309   bool ok = true;
00310   ++m_neighbours_iterator;
00311 
00312   // end of a neighbourhood
00313   if ( m_neighbours_iterator == m_vertex_iterator->second.end() )
00314     {
00315       // find next edge or end.
00316       ok = false;
00317       ++m_vertex_iterator;
00318 
00319       while ( (m_vertex_iterator != m_vertex_end) && !ok )
00320         if ( !m_vertex_iterator->second.empty() )
00321           {
00322             ok = true;
00323             m_neighbours_iterator = m_vertex_iterator->second.begin();
00324           }
00325         else
00326           ++m_vertex_iterator;
00327     }
00328 
00329   if (ok)
00330     m_edge.set( m_neighbours_iterator->second, m_vertex_iterator->first,
00331                 m_neighbours_iterator->first );
00332 
00333   return *this;
00334 } // 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]

Postincrement.

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

Definition at line 343 of file graph.tpp.

00344 {
00345   graph_edge_iterator it_tmp(*this);
00346   ++(*this);
00347   return it_tmp;
00348 } // 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]

Predecrement.

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

Definition at line 357 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().

00358 {
00359   bool ok = true;
00360 
00361   if (m_vertex_iterator == m_vertex_end)
00362     {
00363       --m_vertex_iterator;
00364       m_neighbours_iterator = m_vertex_iterator->second.end();
00365     }
00366 
00367   // begining of a neighbourhood
00368   if ( m_neighbours_iterator == m_vertex_iterator->second.begin() )
00369     {
00370       ok = false;
00371       // find previous edge or begining.
00372       while ( (m_vertex_iterator != m_vertex_begin) && !ok )
00373         {
00374           --m_vertex_iterator;
00375           if ( !m_vertex_iterator->second.empty() )
00376             {
00377               ok = true;
00378               m_neighbours_iterator = --m_vertex_iterator->second.end();
00379             }
00380         }
00381     }
00382   else
00383     --m_neighbours_iterator;
00384 
00385   if (!ok)
00386     m_vertex_iterator == m_vertex_end;
00387   else
00388     m_edge.set( m_neighbours_iterator->second, m_vertex_iterator->first,
00389                 m_neighbours_iterator->first );
00390 
00391   return *this;
00392 } // operator--() [predecrement]

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 401 of file graph.tpp.

00402 {
00403   graph_edge_iterator it_tmp(*this);
00404   --(*this);
00405   return it_tmp;
00406 } // operator--() [postdecrement]

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 415 of file graph.tpp.

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

00416 {
00417   return m_edge;
00418 } // operator*()

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 427 of file graph.tpp.

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

00428 {
00429   return &m_edge;
00430 } // 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 440 of file graph.tpp.

References 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, and claw::graph< S, A, Comp >::graph_edge_iterator::m_vertex_iterator.

00441 {
00442   // both are empty
00443   if ( m_vertex_begin == m_vertex_end )
00444     return (it.m_vertex_begin == it.m_vertex_end) 
00445       && (m_vertex_begin == it.m_vertex_begin);
00446   else
00447     if ( it.m_vertex_begin == it.m_vertex_end ) // -it- is empty
00448       return false;
00449     else
00450       // none is empty, perheaps at the end ?
00451       if (m_vertex_iterator == m_vertex_end)
00452         return (it.m_vertex_iterator == it.m_vertex_end)
00453           && (m_vertex_begin == it.m_vertex_begin);
00454       else
00455         if (it.m_vertex_iterator == it.m_vertex_end)
00456           return false;
00457         else
00458           return m_neighbours_iterator == it.m_neighbours_iterator;
00459 } // 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]

Difference.

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

Definition at line 469 of file graph.tpp.

00470 {
00471   return !(*this == it);
00472 } // operator!=()


Friends And Related Function Documentation

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

Definition at line 151 of file graph.hpp.


Member Data Documentation

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

template<class S, class A, 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, class Comp = std::less<S>>
graph_content::const_iterator claw::graph< S, A, Comp >::graph_edge_iterator::m_vertex_iterator [private]

template<class S, class A, 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, class Comp = std::less<S>>
edge claw::graph< S, A, Comp >::graph_edge_iterator::m_edge [private]


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

Generated on Thu Jun 26 09:35:05 2008 for CLAW Library (a C++ Library Absolutely Wonderful) by  doxygen 1.5.6