Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:37:10

0001 //
0002 //=======================================================================
0003 // Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
0004 // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
0005 //
0006 // Distributed under the Boost Software License, Version 1.0. (See
0007 // accompanying file LICENSE_1_0.txt or copy at
0008 // http://www.boost.org/LICENSE_1_0.txt)
0009 //=======================================================================
0010 //
0011 #ifndef BOOST_GRAPH_DETAIL_INCIDENCE_ITERATOR_HPP
0012 #define BOOST_GRAPH_DETAIL_INCIDENCE_ITERATOR_HPP
0013 
0014 #include <utility>
0015 #include <iterator>
0016 
0017 // OBSOLETE
0018 
0019 namespace boost
0020 {
0021 
0022 namespace detail
0023 {
0024     // EdgeDir tags
0025     struct in_edge_tag
0026     {
0027     };
0028     struct out_edge_tag
0029     {
0030     };
0031 
0032     template < class Vertex, class Edge, class Iterator1D, class EdgeDir >
0033     struct bidir_incidence_iterator
0034     {
0035         typedef bidir_incidence_iterator self;
0036         typedef Edge edge_type;
0037         typedef typename Edge::property_type EdgeProperty;
0038 
0039     public:
0040         typedef int difference_type;
0041         typedef std::forward_iterator_tag iterator_category;
0042         typedef edge_type reference;
0043         typedef edge_type value_type;
0044         typedef value_type* pointer;
0045         inline bidir_incidence_iterator() {}
0046         inline bidir_incidence_iterator(Iterator1D ii, Vertex src)
0047         : i(ii), _src(src)
0048         {
0049         }
0050 
0051         inline self& operator++()
0052         {
0053             ++i;
0054             return *this;
0055         }
0056         inline self operator++(int)
0057         {
0058             self tmp = *this;
0059             ++(*this);
0060             return tmp;
0061         }
0062 
0063         inline reference operator*() const { return deref_helper(EdgeDir()); }
0064         inline self* operator->() { return this; }
0065 
0066         Iterator1D& iter() { return i; }
0067         const Iterator1D& iter() const { return i; }
0068 
0069         Iterator1D i;
0070         Vertex _src;
0071 
0072     protected:
0073         inline reference deref_helper(out_edge_tag) const
0074         {
0075             return edge_type(_src, (*i).get_target(), &(*i).get_property());
0076         }
0077         inline reference deref_helper(in_edge_tag) const
0078         {
0079             return edge_type((*i).get_target(), _src, &(*i).get_property());
0080         }
0081     };
0082 
0083     template < class V, class E, class Iter, class Dir >
0084     inline bool operator==(const bidir_incidence_iterator< V, E, Iter, Dir >& x,
0085         const bidir_incidence_iterator< V, E, Iter, Dir >& y)
0086     {
0087         return x.i == y.i;
0088     }
0089     template < class V, class E, class Iter, class Dir >
0090     inline bool operator!=(const bidir_incidence_iterator< V, E, Iter, Dir >& x,
0091         const bidir_incidence_iterator< V, E, Iter, Dir >& y)
0092     {
0093         return x.i != y.i;
0094     }
0095 
0096 }
0097 }
0098 #endif