annotate DEPENDENCIES/generic/include/boost/graph/detail/edge.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
rev   line source
Chris@16 1 //
Chris@16 2 //=======================================================================
Chris@16 3 // Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
Chris@16 4 // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
Chris@16 5 //
Chris@16 6 // Distributed under the Boost Software License, Version 1.0. (See
Chris@16 7 // accompanying file LICENSE_1_0.txt or copy at
Chris@16 8 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9 //=======================================================================
Chris@16 10
Chris@16 11 #ifndef BOOST_GRAPH_DETAIL_EDGE_HPP
Chris@16 12 #define BOOST_GRAPH_DETAIL_EDGE_HPP
Chris@16 13
Chris@16 14 #if __GNUC__ < 3
Chris@16 15 #include <iostream>
Chris@16 16 #else
Chris@16 17 #include <iosfwd>
Chris@16 18 #endif
Chris@16 19
Chris@16 20 namespace boost {
Chris@16 21
Chris@16 22 namespace detail {
Chris@16 23
Chris@16 24 template <typename Directed, typename Vertex>
Chris@16 25 struct edge_base
Chris@16 26 {
Chris@16 27 inline edge_base() {}
Chris@16 28 inline edge_base(Vertex s, Vertex d)
Chris@16 29 : m_source(s), m_target(d) { }
Chris@16 30 Vertex m_source;
Chris@16 31 Vertex m_target;
Chris@16 32 };
Chris@16 33
Chris@16 34 template <typename Directed, typename Vertex>
Chris@16 35 class edge_desc_impl : public edge_base<Directed,Vertex> {
Chris@16 36 typedef edge_desc_impl self;
Chris@16 37 typedef edge_base<Directed,Vertex> Base;
Chris@16 38 public:
Chris@16 39 typedef void property_type;
Chris@16 40
Chris@16 41 inline edge_desc_impl() : m_eproperty(0) {}
Chris@16 42
Chris@16 43 inline edge_desc_impl(Vertex s, Vertex d, const property_type* eplug)
Chris@16 44 : Base(s,d), m_eproperty(const_cast<property_type*>(eplug)) { }
Chris@16 45
Chris@16 46 property_type* get_property() { return m_eproperty; }
Chris@16 47 const property_type* get_property() const { return m_eproperty; }
Chris@16 48
Chris@16 49 // protected:
Chris@16 50 property_type* m_eproperty;
Chris@16 51 };
Chris@16 52
Chris@16 53 template <class D, class V>
Chris@16 54 inline bool
Chris@16 55 operator==(const detail::edge_desc_impl<D,V>& a,
Chris@16 56 const detail::edge_desc_impl<D,V>& b)
Chris@16 57 {
Chris@16 58 return a.get_property() == b.get_property();
Chris@16 59 }
Chris@16 60 template <class D, class V>
Chris@16 61 inline bool
Chris@16 62 operator!=(const detail::edge_desc_impl<D,V>& a,
Chris@16 63 const detail::edge_desc_impl<D,V>& b)
Chris@16 64 {
Chris@16 65 return ! (a.get_property() == b.get_property());
Chris@16 66 }
Chris@16 67
Chris@16 68 // Order edges according to the address of their property object
Chris@16 69 template <class D, class V>
Chris@16 70 inline bool
Chris@16 71 operator<(const detail::edge_desc_impl<D,V>& a,
Chris@16 72 const detail::edge_desc_impl<D,V>& b)
Chris@16 73 {
Chris@16 74 return a.get_property() < b.get_property();
Chris@16 75 }
Chris@16 76 template <class D, class V>
Chris@16 77 inline bool
Chris@16 78 operator<=(const detail::edge_desc_impl<D,V>& a,
Chris@16 79 const detail::edge_desc_impl<D,V>& b)
Chris@16 80 {
Chris@16 81 return a.get_property() <= b.get_property();
Chris@16 82 }
Chris@16 83 template <class D, class V>
Chris@16 84 inline bool
Chris@16 85 operator>(const detail::edge_desc_impl<D,V>& a,
Chris@16 86 const detail::edge_desc_impl<D,V>& b)
Chris@16 87 {
Chris@16 88 return a.get_property() > b.get_property();
Chris@16 89 }
Chris@16 90 template <class D, class V>
Chris@16 91 inline bool
Chris@16 92 operator>=(const detail::edge_desc_impl<D,V>& a,
Chris@16 93 const detail::edge_desc_impl<D,V>& b)
Chris@16 94 {
Chris@16 95 return a.get_property() >= b.get_property();
Chris@16 96 }
Chris@16 97
Chris@16 98 } //namespace detail
Chris@16 99
Chris@16 100 } // namespace boost
Chris@16 101
Chris@16 102 namespace std {
Chris@16 103
Chris@16 104 #if __GNUC__ < 3
Chris@16 105 template <class D, class V>
Chris@16 106 std::ostream&
Chris@16 107 operator<<(std::ostream& os, const boost::detail::edge_desc_impl<D,V>& e)
Chris@16 108 {
Chris@16 109 return os << "(" << e.m_source << "," << e.m_target << ")";
Chris@16 110 }
Chris@16 111 #else
Chris@16 112 template <class Char, class Traits, class D, class V>
Chris@16 113 std::basic_ostream<Char, Traits>&
Chris@16 114 operator<<(std::basic_ostream<Char, Traits>& os,
Chris@16 115 const boost::detail::edge_desc_impl<D,V>& e)
Chris@16 116 {
Chris@16 117 return os << "(" << e.m_source << "," << e.m_target << ")";
Chris@16 118 }
Chris@16 119 #endif
Chris@16 120
Chris@16 121 }
Chris@16 122
Chris@16 123
Chris@16 124 #endif // BOOST_GRAPH_DETAIL_DETAIL_EDGE_HPP