2017: Fix the insertion of edges into a graph.

https://svn.lrde.epita.fr/svn/oln/trunk/milena This bug has probably been there for weeks... (Since the introduction of graph_base<V, E>::edges_set_, to be specific.) Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Fix the insertion of edges into a graph. * mln/util/internal/graph_base.hh (mln::util::internal::less_ptr<T>): New functor. Use it... (mln::util::internal::graph_base<V, E>::edges_set_t): ...here, to fix the comparison of edges, and have the search for an existing edge in graph_base<V, E>::add_edge_ work. graph_base.hh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) Index: mln/util/internal/graph_base.hh --- mln/util/internal/graph_base.hh (revision 2016) +++ mln/util/internal/graph_base.hh (working copy) @@ -196,6 +196,21 @@ namespace internal { + // FIXME: This should be no longer useful once vertices and edges + // are handled without pointers and dynamic allocation. + template <typename T> + struct less_ptr + { + bool + operator()(const T& a, const T& b) + { + mln_assertion(a); + mln_assertion(b); + return (*a < *b); + } + }; + + /// \brief Base class for undirected graphs. template<typename V, typename E> class graph_base @@ -211,7 +226,8 @@ /// The type of the set of edges. typedef std::vector< util::edge<E>* > edges_t; /// A set to test the presence of a given edge. - typedef std::set< util::edge<E>* > edges_set_t; + typedef std::set< util::edge<E>*, + less_ptr< util::edge<E>* > > edges_set_t; /// Construction, assignments and destruction. /// \{
participants (1)
-
Roland Levillain