URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-21 Michel Pellegrin <pellegrin(a)lrde.epita.fr>
Fix some typos, add existant tests.
* sandbox/pellegrin/set/Makefile: Remove.
* sandbox/pellegrin/set/core/concept/point_set.hh: Modified.
* sandbox/pellegrin/set/core/internal/multi_set.hh,
* sandbox/pellegrin/set/core/internal/uni_set.hh: New.
* sandbox/pellegrin/set/core/line2d.hh,
* sandbox/pellegrin/set/core/p_array.hh,
* sandbox/pellegrin/set/core/p_bgraph.hh,
* sandbox/pellegrin/set/core/p_graph.hh,
* sandbox/pellegrin/set/core/p_line_graph.hh,
* sandbox/pellegrin/set/core/p_priority_queue.hh,
* sandbox/pellegrin/set/core/p_priority_queue_fast.hh,
* sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh,
* sandbox/pellegrin/set/core/p_queue.hh,
* sandbox/pellegrin/set/core/p_queue_fast.hh,
* sandbox/pellegrin/set/core/p_run.hh,
* sandbox/pellegrin/set/core/p_runs.hh,
* sandbox/pellegrin/set/core/p_set.hh,
* sandbox/pellegrin/set/core/pset_if.hh: Modify an #include and add a
semi-colon after the trait struct.
* sandbox/pellegrin/set/multi_set.hh: Remove.
* sandbox/pellegrin/set/test: New folder containing tests.
* sandbox/pellegrin/set/test/Makefile,
* sandbox/pellegrin/set/test/test.sh,
* sandbox/pellegrin/set/test/detest.sh: New, for the compilation.
* sandbox/pellegrin/set/test/p_bgraph.cc,
* sandbox/pellegrin/set/test/p_priority_queue.cc,
* sandbox/pellegrin/set/test/p_priority_queue_fast.cc,
* sandbox/pellegrin/set/test/p_priority_queue_fast_with_array.cc,
* sandbox/pellegrin/set/test/p_queue.cc,
* sandbox/pellegrin/set/test/p_queue_fast.cc,
* sandbox/pellegrin/set/test/p_runs.cc,
* sandbox/pellegrin/set/test/p_set.cc,
* sandbox/pellegrin/set/test/pset_if.cc: New tests.
* sandbox/pellegrin/set/test_set.cc: Remove.
* sandbox/pellegrin/set/trait/point_set.hh: Minor fix.
* sandbox/pellegrin/set/uni_set.hh: Remove.
---
core/concept/point_set.hh | 8 -
core/internal/multi_set.hh | 176 +++++++++++++++++++++++++++++++
core/internal/uni_set.hh | 176 +++++++++++++++++++++++++++++++
core/line2d.hh | 4
core/p_array.hh | 4
core/p_bgraph.hh | 4
core/p_graph.hh | 4
core/p_line_graph.hh | 4
core/p_priority_queue.hh | 10 -
core/p_priority_queue_fast.hh | 4
core/p_priority_queue_fast_with_array.hh | 8 -
core/p_queue.hh | 4
core/p_queue_fast.hh | 4
core/p_run.hh | 4
core/p_runs.hh | 4
core/p_set.hh | 4
core/pset_if.hh | 4
test/Makefile | 16 ++
test/detest.sh | 17 ++
test/p_bgraph.cc | 85 ++++++++++++++
test/p_priority_queue.cc | 98 +++++++++++++++++
test/p_priority_queue_fast.cc | 98 +++++++++++++++++
test/p_priority_queue_fast_with_array.cc | 105 ++++++++++++++++++
test/p_queue.cc | 57 ++++++++++
test/p_queue_fast.cc | 57 ++++++++++
test/p_runs.cc | 82 ++++++++++++++
test/p_set.cc | 57 ++++++++++
test/pset_if.cc | 53 +++++++++
test/test.sh | 18 +++
trait/point_set.hh | 2
30 files changed, 1130 insertions(+), 41 deletions(-)
Index: trunk/milena/sandbox/pellegrin/set/multi_set.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/pellegrin/set/uni_set.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/pellegrin/set/Makefile (deleted)
===================================================================
Index: trunk/milena/sandbox/pellegrin/set/test_set.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/pellegrin/set/test/detest.sh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/detest.sh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/detest.sh (revision 1794)
@@ -0,0 +1,17 @@
+#! /bin/sh
+
+lol="line2d.hh p_bgraph.hh p_line_graph.hh p_priority_queue_fast_with_array.hh
+p_queue_fast.hh p_run.hh p_set.hh p_array.hh p_graph.hh p_priority_queue_fast.hh
+p_priority_queue.hh p_queue.hh p_runs.hh pset_if.hh"
+mln_path="../../../../mln"
+
+if ! [ -f $mln_path/core/stamp ]; then
+ exit 1;
+fi
+
+for i in $lol;
+do
+ mv -v $mln_path/core/$i.bak $mln_path/core/$i;
+done
+
+rm -v $mln_path/core/stamp
Property changes on: trunk/milena/sandbox/pellegrin/set/test/detest.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/pellegrin/set/test/p_queue_fast.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_queue_fast.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_queue_fast.cc (revision 1794)
@@ -0,0 +1,57 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_queue_fast.cc
+ *
+ * \brief Tests on mln::p_queue_fast.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_queue_fast.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ p_queue_fast<point2d> q;
+ q
+ .push(make::point2d(6, 9))
+ .push(make::point2d(5, 1))
+ .push(make::point2d(4, 2));
+ mln_assertion(q.npoints() == 3);
+
+ std::cout << q.bbox() << std::endl;
+ std::cout << q << std::endl;
+
+ q.pop();
+ mln_assertion(q.npoints() == 2);
+ point2d p = q.front();
+ mln_assertion(q.npoints() == 2);
+ mln_assertion(p == make::point2d(5, 1));
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast.cc (revision 1794)
@@ -0,0 +1,98 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_priority_queue_fast.cc
+ *
+ * \brief Tests on mln::p_priority_queue_fast.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_priority_queue_fast.hh>
+
+int main ()
+{
+ using namespace mln;
+
+ mln::p_priority_queue_fast<point2d, unsigned> q;
+ point2d p1 (6, 9);
+ point2d p2 (5, 1);
+ point2d p3 (4, 2);
+
+ mln_assertion (q.is_empty ());
+
+ mln_assertion (q.npoints () == 0);
+
+ q.push_force (p3);
+ q.push_force (p1, 3);
+ q.push_force (p2, 5);
+
+ std::cout << q.bbox () << std::endl;
+ std::cout << q << std::endl;
+
+ mln_assertion (!q.is_empty ());
+
+ mln_assertion (q.has (p1));
+ mln_assertion (q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 3);
+ mln_assertion (q.front () == p2);
+ q.pop ();
+
+ mln_assertion (q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 2);
+ mln_assertion (q.front () == p1);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 1);
+ mln_assertion (q.front () == p3);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (!q.has (p3));
+ mln_assertion (q.npoints () == 0);
+
+ mln_assertion (q.is_empty ());
+
+ q.push_force (p3);
+ q.push_force (p2, 5);
+ q.push_force (p1, 3);
+
+ mln_assertion (q[2] == p3);
+ mln_assertion (q[1] == p1);
+ mln_assertion (q[0] == p2);
+ q.clear ();
+ mln_assertion (q.is_empty ());
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_bgraph.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_bgraph.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_bgraph.cc (revision 1794)
@@ -0,0 +1,85 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/core/p_bgraph.cc
+/// \brief Tests on mln::p_bgraph (the psite based on boost-graph).
+
+#include "../core/p_bgraph.hh"
+#include <mln/core/point2d.hh>
+#include <mln/util/internal/boost_graph.hh>
+#include <boost/typeof/std/utility.hpp>
+
+struct empty {};
+
+int main()
+{
+ /*--------------.
+ | boost_graph. |
+ `--------------*/
+
+ using namespace mln;
+ typedef util::internal::boost_graph<point2d, util::empty> Graph;
+
+ // Make convenient labels for the vertices
+ const int num_vertices = 5;
+
+ // writing out the edges in the graph
+ typedef std::pair<int, int> Edge;
+ Edge edge_array[] = {
+ Edge(0, 1), Edge(0, 3), Edge(2, 0), Edge(3, 2),
+ Edge(2, 4), Edge(1, 3), Edge(3, 4)
+ };
+
+ const int num_edges = sizeof(edge_array)/sizeof(edge_array[0]);
+ // declare a graph object
+ Graph g(num_vertices);
+
+ // add the edges to the graph object
+ for (int i = 0; i < num_edges; ++i)
+ boost::add_edge(edge_array[i].first, edge_array[i].second, g);
+
+ g[0] = make::point2d(0, 0);
+ g[1] = make::point2d(0, 1);
+ g[2] = make::point2d(1, 0);
+ g[3] = make::point2d(1, 1);
+ g[4] = make::point2d(0, 2);
+
+ /*-----------.
+ | p_bgraph. |
+ `-----------*/
+
+ /// Creation
+ p_bgraph<point2d> pset(&g);
+
+ /// Iterator
+ p_bgraph_piter_<point2d> p(pset);
+
+ for (p.start(); p.is_valid(); p.next())
+ std::cout << p << std::endl;
+
+ return 0;
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_queue.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_queue.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_queue.cc (revision 1794)
@@ -0,0 +1,57 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_queue.cc
+ *
+ * \brief Tests on mln::p_queue.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_queue.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ p_queue<point2d> q;
+ q
+ .push(make::point2d(6, 9))
+ .push(make::point2d(5, 1))
+ .push(make::point2d(4, 2));
+ mln_assertion(q.npoints() == 3);
+
+ std::cout << q.bbox() << std::endl;
+ std::cout << q << std::endl;
+
+ q.pop();
+ mln_assertion(q.npoints() == 2);
+ point2d p = q.front();
+ mln_assertion(q.npoints() == 2);
+ mln_assertion(p == make::point2d(5, 1));
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_priority_queue.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_priority_queue.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_priority_queue.cc (revision 1794)
@@ -0,0 +1,98 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_priority_queue.cc
+ *
+ * \brief Tests on mln::p_priority_queue.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_priority_queue.hh>
+
+int main ()
+{
+ using namespace mln;
+
+ p_priority_queue<point2d, unsigned> q;
+ point2d p1 (6, 9);
+ point2d p2 (5, 1);
+ point2d p3 (4, 2);
+
+ mln_assertion (q.is_empty ());
+
+ mln_assertion (q.npoints () == 0);
+
+ q.push_force (p3);
+ q.push_force (p1, 3);
+ q.push_force (p2, 5);
+
+ std::cout << q.bbox () << std::endl;
+ std::cout << q << std::endl;
+
+ mln_assertion (!q.is_empty ());
+
+ mln_assertion (q.has (p1));
+ mln_assertion (q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 3);
+ mln_assertion (q.front () == p2);
+ q.pop ();
+
+ mln_assertion (q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 2);
+ mln_assertion (q.front () == p1);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 1);
+ mln_assertion (q.front () == p3);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (!q.has (p3));
+ mln_assertion (q.npoints () == 0);
+
+ mln_assertion (q.is_empty ());
+
+ q.push_force (p3);
+ q.push_force (p2, 5);
+ q.push_force (p1, 3);
+
+ mln_assertion (q[2] == p3);
+ mln_assertion (q[1] == p1);
+ mln_assertion (q[0] == p2);
+ q.clear ();
+ mln_assertion (q.is_empty ());
+}
Index: trunk/milena/sandbox/pellegrin/set/test/test.sh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/test.sh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/test.sh (revision 1794)
@@ -0,0 +1,18 @@
+#! /bin/sh
+
+lol="line2d.hh p_bgraph.hh p_line_graph.hh p_priority_queue_fast_with_array.hh
+p_queue_fast.hh p_run.hh p_set.hh p_array.hh p_graph.hh p_priority_queue_fast.hh
+p_priority_queue.hh p_queue.hh p_runs.hh pset_if.hh"
+mln_path="../../../../mln"
+
+if [ -f $mln_path/core/stamp ]; then
+ exit 1;
+fi
+
+for i in $lol;
+do
+ mv -v $mln_path/core/$i $mln_path/core/$i.bak;
+ cp -v ../core/$i $mln_path/core/;
+done
+
+touch $mln_path/core/stamp
Property changes on: trunk/milena/sandbox/pellegrin/set/test/test.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/pellegrin/set/test/p_runs.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_runs.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_runs.cc (revision 1794)
@@ -0,0 +1,82 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_runs.cc
+ *
+ * \brief Test on mln::p_runs_ and related tools.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/p_runs.hh>
+
+
+template <typename Pset>
+void parc(const Pset& pset)
+{
+ mln_fwd_piter(Pset) it_(pset);
+ for_all(it_)
+ std::cout << it_ << std::endl;
+
+ mln_bkd_piter(Pset) rit_(pset);
+ for_all(rit_)
+ std::cout << rit_ << std::endl;
+}
+
+
+int main()
+{
+ using namespace mln;
+
+ point2d p, q, r;
+ p = make::point2d(2, 4);
+ q = make::point2d(18, 42);
+ r = make::point2d(50, 76);
+
+ // Pset test
+ p_runs_<point2d> ps;
+ p_runs_<point2d> ps2;
+
+ ps.insert(p_run<point2d>(p, 7));
+ mln_assertion(ps.npoints() == 7);
+
+ ps.insert(p_run<point2d>(q, 5));
+ mln_assertion(ps.npoints() == 12);
+
+ ps.insert(p_run<point2d>(r, 2));
+
+ ps.insert(p_run<point2d>(make::point2d(17,40), 6));
+
+ // Psite declaration
+ runs_psite<point2d> site(ps, 5, 0);
+ runs_psite<point2d> site2(ps, 5, 1);
+
+ mln_assertion(ps.has(site));
+ mln_assertion(!ps2.has(site2));
+
+
+ parc(ps);
+}
Index: trunk/milena/sandbox/pellegrin/set/test/pset_if.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/pset_if.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/pset_if.cc (revision 1794)
@@ -0,0 +1,53 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core_pset_if.cc
+ *
+ * \brief Tests on mln::pset_if.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/p_set.hh>
+#include <mln/core/pset_if.hh>
+#include <mln/fun/p2b/chess.hh>
+#include <mln/convert/to_image.hh>
+#include <mln/convert/to_p_set.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ box2d box_8x8 = make::box2d(8, 8);
+ mln_assertion((box_8x8 | fun::p2b::chess).npoints() == 32);
+
+ {
+ p_set<point2d> s = convert::to_p_set(box_8x8 | fun::p2b::chess);
+ std::cout << (box_8x8 | fun::p2b::chess) << std::endl;
+ std::cout << s << std::endl;
+ }
+}
Index: trunk/milena/sandbox/pellegrin/set/test/Makefile
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/Makefile (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/Makefile (revision 1794)
@@ -0,0 +1,16 @@
+all:
+ ./test.sh
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_bgraph.cc -o
bgraph
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_priority_queue.cc
-o priority_queue
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../
p_priority_queue_fast.cc -o priority_queue_fast
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../
p_priority_queue_fast_with_array.cc -o priority_queue_fast_with_array
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_queue.cc -o
queue
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_queue_fast.cc -o
queue_fast
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_runs.cc -o runs
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_set.cc -o set
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ pset_if.cc -o
pset_if
+ ./detest.sh
+
+clean:
+ rm -vf bgraph priority_queue priority_queue_fast priority_queue_fast_with_array \
+ queue queue_fast runs set pset_if
Index: trunk/milena/sandbox/pellegrin/set/test/p_set.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_set.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_set.cc (revision 1794)
@@ -0,0 +1,57 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core_p_set.cc
+ *
+ * \brief Tests on mln::p_set.
+ */
+
+#include <iterator>
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_set.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ p_set<point2d> ps;
+ ps
+ .insert(make::point2d(6, 9))
+ .insert(make::point2d(4, 2))
+ .insert(make::point2d(4, 2))
+ .insert(make::point2d(5, 1));
+ mln_assertion(ps.npoints() == 3);
+
+ std::cout << ps.bbox() << std::endl;
+
+ std::copy(ps.vect().begin(), ps.vect().end(),
+ std::ostream_iterator<point2d>(std::cout, " "));
+ std::cout << std::endl;
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast_with_array.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast_with_array.cc (revision
0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast_with_array.cc (revision
1794)
@@ -0,0 +1,105 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_priority_queue_fast_with_array.cc
+ *
+ * \brief Tests on mln::p_priority_queue_fast_with_array.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_priority_queue_fast_with_array.hh>
+
+int main ()
+{
+ using namespace mln;
+
+ p_priority_queue_fast_with_array<point2d, unsigned, 20> q;
+ point2d p1 (6, 9);
+ point2d p2 (5, 1);
+ point2d p3 (4, 2);
+
+ mln_assertion (q.is_empty ());
+ mln_assertion (q.npoints () == 0);
+
+ q.push_force (p3);
+ mln_assertion (!q.is_empty ());
+ mln_assertion (q.npoints () == 1);
+
+ q.push_force (p1, 3);
+ mln_assertion (!q.is_empty ());
+ mln_assertion (q.npoints () == 2);
+
+ q.push_force (p2, 5);
+ mln_assertion (!q.is_empty ());
+ mln_assertion (q.npoints () == 3);
+
+ std::cout << q.bbox () << std::endl;
+ std::cout << q << std::endl;
+
+ mln_assertion (!q.is_empty ());
+
+ mln_assertion (q.has (p1));
+ mln_assertion (q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 3);
+ mln_assertion (q.front () == p2);
+ q.pop ();
+
+ mln_assertion (q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 2);
+ mln_assertion (q.front () == p1);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 1);
+ mln_assertion (q.front () == p3);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (!q.has (p3));
+ mln_assertion (q.npoints () == 0);
+
+ mln_assertion (q.is_empty ());
+
+ q.push_force (p3);
+ q.push_force (p2, 5);
+ q.push_force (p1, 3);
+
+ mln_assertion (q[2] == p3);
+ mln_assertion (q[1] == p1);
+ mln_assertion (q[0] == p2);
+ q.clear ();
+ mln_assertion (q.is_empty ());
+}
Index: trunk/milena/sandbox/pellegrin/set/trait/point_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/trait/point_set.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/trait/point_set.hh (revision 1794)
@@ -49,7 +49,7 @@
template <typename P> struct p_line_graph;
template <typename P, typename T> struct p_priority_queue;
template <typename P, typename T> struct p_priority_queue_fast;
- template <typename P, typename T, typename S> struct
p_priority_queue_fast_with_array;
+ template <typename P, typename T, unsigned S> struct
p_priority_queue_fast_with_array;
template <typename P> struct p_queue;
template <typename P> struct p_queue_fast;
template <typename P> struct p_run;
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh (revision 1794)
@@ -44,7 +44,7 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue_fast.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -64,7 +64,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh (revision 1794)
@@ -39,7 +39,7 @@
# include <mln/util/internal/boost_graph.hh>
# include <mln/core/bgraph_psite.hh>
# include <mln/core/p_bgraph_piter.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -57,7 +57,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_run.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_run.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_run.hh (revision 1794)
@@ -36,7 +36,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/internal/set_of.hh>
# include <mln/accu/bbox.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -55,7 +55,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh (revision 1794)
@@ -35,7 +35,7 @@
# include <mln/core/line_graph_psite.hh>
# include <mln/core/p_line_graph_piter.hh>
# include <mln/core/point_pair.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
/* FIXME: This class shares a lot with p_graph. Factor as much as
@@ -67,7 +67,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/pset_if.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/pset_if.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/pset_if.hh (revision 1794)
@@ -35,7 +35,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/concept/function.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -54,7 +54,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::slow has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_array.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_array.hh (revision 1794)
@@ -37,7 +37,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/accu/bbox.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -56,7 +56,7 @@
{
typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh (revision 1794)
@@ -38,7 +38,7 @@
# include <mln/core/concept/point_site.hh>
# include <mln/core/concept/point_iterator.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -96,7 +96,6 @@
bool operator==(const Point_Set<Sl>& lhs, const Point_Set<Sr>&
rhs);
-
/*! \brief Inclusion test between point sets \p lhs and \p rhs.
*
* \param[in] lhs A point set (included?).
@@ -108,7 +107,6 @@
bool operator<=(const Point_Set<Sl>& lhs, const Point_Set<Sr>&
rhs);
-
/*! \brief Strict inclusion test between point sets \p lhs and \p
* rhs.
*
@@ -121,7 +119,6 @@
bool operator<(const Point_Set<Sl>& lhs, const Point_Set<Sr>&
rhs);
-
/*! \brief Print a point set \p pset into the output stream \p
* ostr.
*
@@ -136,7 +133,6 @@
std::ostream& operator<<(std::ostream& ostr, const
Point_Set<S>& pset);
-
# ifndef MLN_INCLUDE_ONLY
// fwd decl
@@ -245,8 +241,6 @@
} // end of namespace mln
-
# include <mln/core/ops.hh>
-
#endif // ! MLN_CORE_CONCEPT_POINT_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_queue.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_queue.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_queue.hh (revision 1794)
@@ -41,7 +41,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -60,7 +60,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::slow has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh (revision 1794)
@@ -44,7 +44,7 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -58,13 +58,13 @@
namespace trait
{
- template <typename P>
- struct point_set_< p_priority_queue<P> >
- : public default_point_set_< p_priority_queue<P> >
+ template <typename P, typename T>
+ struct point_set_< p_priority_queue<P, T> >
+ : public default_point_set_< p_priority_queue<P, T> >
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::slow has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_runs.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_runs.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_runs.hh (revision 1794)
@@ -42,7 +42,7 @@
# include <mln/core/p_run.hh>
# include <mln/accu/bbox.hh>
# include <mln/util/lazy_set.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -61,7 +61,7 @@
{
typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_set.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_set.hh (revision 1794)
@@ -37,7 +37,7 @@
# include <mln/core/internal/set_of.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_array.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -54,7 +54,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh (revision
1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh (revision
1794)
@@ -44,27 +44,27 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue_fast.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
{
// Fwd decls.
- template <typename P, typename T, typename S> struct
p_priority_queue_fast_with_array;
+ template <typename P, typename T, unsigned S> struct
p_priority_queue_fast_with_array;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
namespace trait
{
- template <typename P, typename T, typename S>
+ template <typename P, typename T, unsigned S>
struct point_set_< p_priority_queue_fast_with_array<P, T, S> >
: public default_point_set_< p_priority_queue_fast_with_array<P, T, S> >
{
typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/line2d.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/line2d.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/line2d.hh (revision 1794)
@@ -39,7 +39,7 @@
# include <mln/core/p_array_piter.hh>
# include <mln/core/box2d.hh>
# include <mln/math/all.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -56,7 +56,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/internal/multi_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/internal/multi_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/internal/multi_set.hh (revision 1794)
@@ -0,0 +1,176 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+
+#ifndef MULTI_SET_HH
+# define MULTI_SET_HH
+
+/*! \file sandbox/pellegrin/set/multi_set.hh
+ *
+ * \brief Definition of a point multi-set class.
+ */
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/internal/set_of.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Point set class.
+ *
+ * This is a mathematical multi-set of points. The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo All.
+ */
+ template <typename P>
+ class multi_set : public internal::point_set_base_< P, p_set<P> >,
+ private internal::set_of_<P>
+ {
+ typedef internal::set_of_<P> super_;
+
+ public:
+ /// Forward Point_Iterator associated type.
+ typedef multi_set_fwd_piter_<P> fwd_piter;
+ /// Backward Point_Iterator associated type.
+ typedef multi_set_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ multi_set();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Return the corresponding std::vector of points.
+ using super_::vect;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Insert a point \p p.
+ multi_set<P>& insert(const P& p);
+
+ // FIXME : doesn't compile
+ // /// Remove a point \p p.
+ // p_set<P>& remove(P& p);
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ /// Clear this set.
+ void clear();
+
+ /// Give the exact bounding box.
+ const box_<mln_point(P)>& bbox() const;
+
+ protected:
+
+ accu::bbox<P> bb_;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ multi_set<P>::multi_set()
+ {
+ }
+
+ template <typename P>
+ inline
+ bool
+ multi_set<P>::has(const P& p) const
+ {
+ return this->super_::has(p);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ multi_set<P>::npoints() const
+ {
+ return this->super_::nelements();
+ }
+
+ template <typename P>
+ inline
+ multi_set<P>&
+ multi_set<P>::insert(const P& p)
+ {
+ this->super_::insert(p);
+ bb_.take(p);
+ return *this;
+ }
+
+
+ // FIXME : finish it.
+ // template <typename P>
+ // p_set<P>&
+ // p_set<P>::remove(P& p)
+ // {
+ // this->super_::remove(p);
+ // // FIXME: need to rebuild bb_ ?
+ // //bb_.untake(p);
+ // return *this;
+ // }
+
+ template <typename P>
+ inline
+ const P&
+ multi_set<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return this->super_::element(i);
+ }
+
+ template <typename P>
+ inline
+ void
+ multi_set<P>::clear()
+ {
+ this->super_::clear();
+ bb_.init();
+ }
+
+ template <typename P>
+ inline
+ const box_<mln_point(P)>&
+ multi_set<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ return bb_.to_result();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MULTI_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/core/internal/uni_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/internal/uni_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/internal/uni_set.hh (revision 1794)
@@ -0,0 +1,176 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+
+#ifndef UNI_SET_HH
+# define UNI_SET_HH
+
+/*! \file sandbox/pellegrin/set/uni_set.hh
+ *
+ * \brief Definition of a point uni-set class.
+ */
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/internal/set_of.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Point set class.
+ *
+ * This is a mathematical uni-set of points (not a multi-set). The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo All.
+ */
+ template <typename P>
+ class uni_set : public internal::point_set_base_< P, p_set<P> >,
+ private internal::set_of_<P>
+ {
+ typedef internal::set_of_<P> super_;
+
+ public:
+ /// Forward Point_Iterator associated type.
+ typedef uni_set_fwd_piter_<P> fwd_piter;
+ /// Backward Point_Iterator associated type.
+ typedef uni_set_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ uni_set();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Return the corresponding std::vector of points.
+ using super_::vect;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Insert a point \p p.
+ uni_set<P>& insert(const P& p);
+
+ // FIXME : doesn't compile
+ // /// Remove a point \p p.
+ // p_set<P>& remove(P& p);
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ /// Clear this set.
+ void clear();
+
+ /// Give the exact bounding box.
+ const box_<mln_point(P)>& bbox() const;
+
+ protected:
+
+ accu::bbox<P> bb_;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ uni_set<P>::uni_set()
+ {
+ }
+
+ template <typename P>
+ inline
+ bool
+ uni_set<P>::has(const P& p) const
+ {
+ return this->super_::has(p);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ uni_set<P>::npoints() const
+ {
+ return this->super_::nelements();
+ }
+
+ template <typename P>
+ inline
+ uni_set<P>&
+ uni_set<P>::insert(const P& p)
+ {
+ this->super_::insert(p);
+ bb_.take(p);
+ return *this;
+ }
+
+
+ // FIXME : finish it.
+ // template <typename P>
+ // p_set<P>&
+ // p_set<P>::remove(P& p)
+ // {
+ // this->super_::remove(p);
+ // // FIXME: need to rebuild bb_ ?
+ // //bb_.untake(p);
+ // return *this;
+ // }
+
+ template <typename P>
+ inline
+ const P&
+ uni_set<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return this->super_::element(i);
+ }
+
+ template <typename P>
+ inline
+ void
+ uni_set<P>::clear()
+ {
+ this->super_::clear();
+ bb_.init();
+ }
+
+ template <typename P>
+ inline
+ const box_<mln_point(P)>&
+ uni_set<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ return bb_.to_result();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! UNI_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_graph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_graph.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_graph.hh (revision 1794)
@@ -34,7 +34,7 @@
# include <mln/util/graph.hh>
# include <mln/core/graph_psite.hh>
# include <mln/core/p_graph_piter.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
/// \file mln/core/p_graph.hh
@@ -55,7 +55,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh (revision 1794)
@@ -42,7 +42,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -61,7 +61,7 @@
{
typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
--
Michel PELLEGRIN
ÉPITA - CSI 2010