Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends

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

Constructor of the graph_edge_iterator class.

Definition at line 275 of file graph.tpp.

{

} // 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 
) [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().

  : m_vertex_begin(it_begin), m_vertex_end(it_end), 
    m_vertex_iterator(it_s), m_neighbours_iterator(it_d)
{
  if (m_vertex_begin != m_vertex_end)
    m_edge.set( m_neighbours_iterator->second, m_vertex_iterator->first,
                m_neighbours_iterator->first );
} // 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

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.

{
  return !(*this == it);
} // 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

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.

{
  return m_edge;
} // 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++ (  ) 

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

{
  bool ok = true;
  ++m_neighbours_iterator;

  // end of a neighbourhood
  if ( m_neighbours_iterator == m_vertex_iterator->second.end() )
    {
      // find next edge or end.
      ok = false;
      ++m_vertex_iterator;

      while ( (m_vertex_iterator != m_vertex_end) && !ok )
        if ( !m_vertex_iterator->second.empty() )
          {
            ok = true;
            m_neighbours_iterator = m_vertex_iterator->second.begin();
          }
        else
          ++m_vertex_iterator;
    }

  if (ok)
    m_edge.set( m_neighbours_iterator->second, m_vertex_iterator->first,
                m_neighbours_iterator->first );

  return *this;
} // 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   ) 

Postincrement.

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

Definition at line 323 of file graph.tpp.

{
  graph_edge_iterator it_tmp(*this);
  ++(*this);
  return it_tmp;
} // 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-- ( int   ) 

postdecrement.

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

Definition at line 381 of file graph.tpp.

{
  graph_edge_iterator it_tmp(*this);
  --(*this);
  return it_tmp;
} // 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-- (  ) 

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

{
  bool ok = true;

  if (m_vertex_iterator == m_vertex_end)
    {
      --m_vertex_iterator;
      m_neighbours_iterator = m_vertex_iterator->second.end();
    }

  // begining of a neighbourhood
  if ( m_neighbours_iterator == m_vertex_iterator->second.begin() )
    {
      ok = false;
      // find previous edge or begining.
      while ( (m_vertex_iterator != m_vertex_begin) && !ok )
        {
          --m_vertex_iterator;
          if ( !m_vertex_iterator->second.empty() )
            {
              ok = true;
              m_neighbours_iterator = --m_vertex_iterator->second.end();
            }
        }
    }
  else
    --m_neighbours_iterator;

  if (!ok)
    m_vertex_iterator == m_vertex_end;
  else
    m_edge.set( m_neighbours_iterator->second, m_vertex_iterator->first,
                m_neighbours_iterator->first );

  return *this;
} // 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

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.

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

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

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.

{
  // both are empty
  if ( m_vertex_begin == m_vertex_end )
    return (it.m_vertex_begin == it.m_vertex_end) 
      && (m_vertex_begin == it.m_vertex_begin);
  else
    if ( it.m_vertex_begin == it.m_vertex_end ) // -it- is empty
      return false;
    else
      // none is empty, perheaps at the end ?
      if (m_vertex_iterator == m_vertex_end)
        return (it.m_vertex_iterator == it.m_vertex_end)
          && (m_vertex_begin == it.m_vertex_begin);
      else
        if (it.m_vertex_iterator == it.m_vertex_end)
          return false;
        else
          return m_neighbours_iterator == it.m_neighbours_iterator;
} // 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: