diff --git a/include/boost/graph/detail/adjacency_list.hpp b/include/boost/graph/detail/adjacency_list.hpp index 1bd98cd9..53c3a779 100644 --- a/include/boost/graph/detail/adjacency_list.hpp +++ b/include/boost/graph/detail/adjacency_list.hpp @@ -1505,51 +1505,6 @@ namespace boost { typedef typename Config::global_edgelist_selector global_edgelist_selector; - - // protected: - - // The edge_dispatch() functions should be static, but - // Borland gets confused about constness. - - // O(E/V) - inline std::pair - edge_dispatch(const AdjList& g, - vertex_descriptor u, vertex_descriptor v, - boost::allow_parallel_edge_tag) const - { - bool found; - const typename Config::OutEdgeList& el = g.out_edge_list(u); - typename Config::OutEdgeList::const_iterator - i = std::find_if(el.begin(), el.end(), - detail::target_is(v)); - found = (i != g.out_edge_list(u).end()); - if (found) - return std::make_pair(edge_descriptor(u, v, &(*i).get_property()), - true); - else - return std::make_pair(edge_descriptor(u, v, 0), false); - } - // O(log(E/V)) - inline std::pair - edge_dispatch(const AdjList& g, - vertex_descriptor u, vertex_descriptor v, - boost::disallow_parallel_edge_tag) const - { - bool found; - /* According to the standard, this should be iterator, not const_iterator, - but the VC++ std::set::find() const returns const_iterator. - And since iterator should be convertible to const_iterator, the - following should work everywhere. -Jeremy */ - typename Config::OutEdgeList::const_iterator - i = g.out_edge_list(u).find(StoredEdge(v)), - end = g.out_edge_list(u).end(); - found = (i != end); - if (found) - return std::make_pair(edge_descriptor(u, v, &(*i).get_property()), - true); - else - return std::make_pair(edge_descriptor(u, v, 0), false); - } }; template @@ -1630,9 +1585,16 @@ namespace boost { const adj_list_helper& g_) { typedef typename Config::graph_type Graph; - typedef typename Config::edge_parallel_category Cat; - const Graph& g = static_cast(g_); - return g_.edge_dispatch(g, u, v, Cat()); + typedef typename Config::StoredEdge StoredEdge; + const Graph& cg = static_cast(g_); + typedef typename Config::out_edge_iterator out_edge_iterator; + const typename Config::OutEdgeList& el = cg.out_edge_list(u); + typename Config::OutEdgeList::const_iterator it = graph_detail:: + find(el, StoredEdge(v)); + return std::make_pair( + typename Config::edge_descriptor + (u, v, (it == el.end() ? 0 : &(*it).get_property())), + (it != el.end())); } template diff --git a/include/boost/pending/container_traits.hpp b/include/boost/pending/container_traits.hpp index 72651d58..7cdf38c7 100644 --- a/include/boost/pending/container_traits.hpp +++ b/include/boost/pending/container_traits.hpp @@ -458,7 +458,67 @@ namespace boost { namespace graph_detail { return push_dispatch(c, v, container_category(c)); } + // Find + template + typename Container::iterator + find_dispatch(Container& c, + const Value& value, + container_tag) + { + return std::find(c.begin(), c.end(), value); + } + + template + typename AssociativeContainer::iterator + find_dispatch(AssociativeContainer& c, + const Value& value, + associative_container_tag) + { + return c.find(value); + } + + template + typename Container::iterator + find(Container& c, + const Value& value) + { + return find_dispatch(c, value, + graph_detail::container_category(c)); + } + + // Find (const versions) + template + typename Container::const_iterator + find_dispatch(const Container& c, + const Value& value, + container_tag) + { + return std::find(c.begin(), c.end(), value); + } + + template + typename AssociativeContainer::const_iterator + find_dispatch(const AssociativeContainer& c, + const Value& value, + associative_container_tag) + { + return c.find(value); + } + + template + typename Container::const_iterator + find(const Container& c, + const Value& value) + { + return find_dispatch(c, value, + graph_detail::container_category(c)); + } + // Equal range +#if 0 + // Make the dispatch fail if c is not an Associative Container (and thus + // doesn't have equal_range unless it is sorted, which we cannot check + // statically and is not typically true for BGL's uses of this function). template std::pair @@ -469,21 +529,22 @@ namespace boost { namespace graph_detail { // c must be sorted for std::equal_range to behave properly. return std::equal_range(c.begin(), c.end(), value); } +#endif - template + template std::pair equal_range_dispatch(AssociativeContainer& c, - const LessThanComparable& value, + const Value& value, associative_container_tag) { return c.equal_range(value); } - template + template std::pair equal_range(Container& c, - const LessThanComparable& value) + const Value& value) { return equal_range_dispatch(c, value, graph_detail::container_category(c));