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_EDGE_HPP
0012 #define BOOST_GRAPH_DETAIL_EDGE_HPP
0013 
0014 #include <iosfwd>
0015 
0016 #include <boost/functional/hash.hpp>
0017 
0018 namespace boost
0019 {
0020 
0021 namespace detail
0022 {
0023 
0024     template < typename Directed, typename Vertex > struct edge_base
0025     {
0026         inline edge_base() {}
0027         inline edge_base(Vertex s, Vertex d) : m_source(s), m_target(d) {}
0028         Vertex m_source;
0029         Vertex m_target;
0030     };
0031 
0032     template < typename Directed, typename Vertex >
0033     class edge_desc_impl : public edge_base< Directed, Vertex >
0034     {
0035         typedef edge_desc_impl self;
0036         typedef edge_base< Directed, Vertex > Base;
0037 
0038     public:
0039         typedef void property_type;
0040 
0041         inline edge_desc_impl() : m_eproperty(0) {}
0042 
0043         inline edge_desc_impl(Vertex s, Vertex d, const property_type* eplug)
0044         : Base(s, d), m_eproperty(const_cast< property_type* >(eplug))
0045         {
0046         }
0047 
0048         property_type* get_property() { return m_eproperty; }
0049         const property_type* get_property() const { return m_eproperty; }
0050 
0051         //  protected:
0052         property_type* m_eproperty;
0053     };
0054 
0055     template < class D, class V >
0056     inline bool operator==(const detail::edge_desc_impl< D, V >& a,
0057         const detail::edge_desc_impl< D, V >& b)
0058     {
0059         return a.get_property() == b.get_property();
0060     }
0061     template < class D, class V >
0062     inline bool operator!=(const detail::edge_desc_impl< D, V >& a,
0063         const detail::edge_desc_impl< D, V >& b)
0064     {
0065         return !(a.get_property() == b.get_property());
0066     }
0067 
0068     // Order edges according to the address of their property object
0069     template < class D, class V >
0070     inline bool operator<(const detail::edge_desc_impl< D, V >& a,
0071         const detail::edge_desc_impl< D, V >& b)
0072     {
0073         return a.get_property() < b.get_property();
0074     }
0075     template < class D, class V >
0076     inline bool operator<=(const detail::edge_desc_impl< D, V >& a,
0077         const detail::edge_desc_impl< D, V >& b)
0078     {
0079         return a.get_property() <= b.get_property();
0080     }
0081     template < class D, class V >
0082     inline bool operator>(const detail::edge_desc_impl< D, V >& a,
0083         const detail::edge_desc_impl< D, V >& b)
0084     {
0085         return a.get_property() > b.get_property();
0086     }
0087     template < class D, class V >
0088     inline bool operator>=(const detail::edge_desc_impl< D, V >& a,
0089         const detail::edge_desc_impl< D, V >& b)
0090     {
0091         return a.get_property() >= b.get_property();
0092     }
0093 
0094 } // namespace detail
0095 
0096 } // namespace boost
0097 
0098 namespace std
0099 {
0100 template < class Char, class Traits, class D, class V >
0101 std::basic_ostream< Char, Traits >& operator<<(
0102     std::basic_ostream< Char, Traits >& os,
0103     const boost::detail::edge_desc_impl< D, V >& e)
0104 {
0105     return os << "(" << e.m_source << "," << e.m_target << ")";
0106 }
0107 }
0108 
0109 // Boost's functional/hash
0110 namespace boost
0111 {
0112 template < typename D, typename V >
0113 struct hash< boost::detail::edge_desc_impl< D, V > >
0114 {
0115     std::size_t operator()(const boost::detail::edge_desc_impl< D, V >& x) const
0116     {
0117         return hash_value(x.get_property());
0118     }
0119 };
0120 }
0121 
0122 #endif // BOOST_GRAPH_DETAIL_DETAIL_EDGE_HPP