3850: Fix compilation issues in graph first search.

* mln/canvas/browsing/internal/graph_first_search.hh: add new routine 'next'. --- milena/ChangeLog | 7 ++++ .../canvas/browsing/internal/graph_first_search.hh | 38 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 06ccdcd..28473f7 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,10 @@ +2009-05-18 Guillaume Lazzara <lazzara@lrde.epita.fr> + + Fix compilation issues in graph first search. + + * mln/canvas/browsing/internal/graph_first_search.hh: add new routine + 'next'. + 2009-05-15 Guillaume Lazzara <lazzara@lrde.epita.fr> Fix tests. diff --git a/milena/mln/canvas/browsing/internal/graph_first_search.hh b/milena/mln/canvas/browsing/internal/graph_first_search.hh index 66020f8..a8f4537 100644 --- a/milena/mln/canvas/browsing/internal/graph_first_search.hh +++ b/milena/mln/canvas/browsing/internal/graph_first_search.hh @@ -66,6 +66,8 @@ */ # include <deque> +# include <queue> +# include <stack> # include <mln/core/concept/iterator.hh> # include <mln/core/concept/browsing.hh> # include <mln/core/concept/graph.hh> @@ -90,7 +92,7 @@ namespace mln class C> class graph_first_search_t : public Browsing< E > { - typedef C<unsigned> container_t; + typedef C<util::vertex_id_t> container_t; public: template <typename G, typename F> void operator()(const Graph<G>&, F& f) const; @@ -100,6 +102,38 @@ namespace mln # ifndef MLN_INCLUDE_ONLY + + /// Call the correct member on the container. + + template <typename T> + inline + util::vertex_id_t + next(const std::queue<T>& queue) + { + return queue.front(); + } + + template <typename T> + inline + util::vertex_id_t + next(const std::stack<T>& stack) + { + return stack.top(); + } + + template <typename S> + inline + util::vertex_id_t + next(const S& stack) + { + /// Not defined yet! + mlc_abort(S)::check(); + return 0; + } + + + + template <typename E, template <typename T, typename Sequence = std::deque<T> > class C> @@ -124,7 +158,7 @@ namespace mln f.new_component_from_vertex(v.id()); // <--- new_component_from_vertex while (!queue.empty()) { - util::vertex<G> current_v = g.vertex(queue.front()); + util::vertex<G> current_v = g.vertex(next(queue)); f.process_vertex(current_v.id()); // <--- process_vertex queue.pop(); for (unsigned nv = 0; nv < current_v.nmax_nbh_vertices(); ++nv) -- 1.5.6.5
participants (1)
-
Guillaume Lazzara