* mln/accu/stat/median_few.hh,
* mln/world/kn/internal/hqueue.hh: Move...
* mln/world/kn/accu/median_few.hh,
* mln/world/kn/hqueue.hh: ... here.
---
milena/ChangeLog | 10 ++
milena/mln/accu/stat/median_few.hh | 147 ----------------------------
milena/mln/world/kn/accu/median_few.hh | 152 +++++++++++++++++++++++++++++
milena/mln/world/kn/hqueue.hh | 160 +++++++++++++++++++++++++++++++
milena/mln/world/kn/internal/hqueue.hh | 165 --------------------------------
5 files changed, 322 insertions(+), 312 deletions(-)
delete mode 100644 milena/mln/accu/stat/median_few.hh
create mode 100644 milena/mln/world/kn/accu/median_few.hh
create mode 100644 milena/mln/world/kn/hqueue.hh
delete mode 100644 milena/mln/world/kn/internal/hqueue.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index addbfff..b3bc9f7 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,15 @@
2012-11-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Move files to proper directories.
+
+ * mln/accu/stat/median_few.hh,
+ * mln/world/kn/internal/hqueue.hh: Move...
+
+ * mln/world/kn/accu/median_few.hh,
+ * mln/world/kn/hqueue.hh: ... here.
+
+2012-11-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Revamp Code.
* mln/world/k1/immerse_with.hh,
diff --git a/milena/mln/accu/stat/median_few.hh b/milena/mln/accu/stat/median_few.hh
deleted file mode 100644
index dd3c16f..0000000
--- a/milena/mln/accu/stat/median_few.hh
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project 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 MLN_ACCU_STAT_MEDIAN_FEW_HH
-# define MLN_ACCU_STAT_MEDIAN_FEW_HH
-
-/// \file
-///
-/// \brief Define a median accumulator class to be used with few
-/// values.
-
-# include <iostream>
-# include <vector>
-# include <algorithm>
-
-# include <mln/trait/routine/mean.hh>
-# include <mln/accu/internal/base.hh>
-
-
-namespace mln
-{
-
- namespace accu
- {
-
- namespace stat
- {
-
- /// \brief Define a median accumulator class to be used with few
- /// values.
- template <typename T,
- typename R = mln_trait_routine_mean(2,T) >
- struct median_few
- : public mln::accu::internal::base< R, median_few<T,R> >
- {
- typedef T argument;
- typedef R result;
-
- median_few();
-
- void reserve(unsigned n);
- void init();
-
- void take(const argument& v);
- void take(const median_few<T,R>& other);
- // nota bene: no possible untake with this accumulator
-
- result to_result() const;
-
- bool is_valid() const;
-
- protected:
-
- mutable std::vector<argument> v_;
- };
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename T, typename R>
- median_few<T,R>::median_few()
- {
- init();
- }
-
- template <typename T, typename R>
- void
- median_few<T,R>::reserve(unsigned n)
- {
- v_.reserve(n);
- }
-
- template <typename T, typename R>
- void
- median_few<T,R>::init()
- {
- v_.clear();
- }
-
- template <typename T, typename R>
- void
- median_few<T,R>::take(const argument& v)
- {
- v_.push_back(v);
- }
-
- template <typename T, typename R>
- void
- median_few<T,R>::take(const median_few<T,R>& other)
- {
- v_.insert(v_.end(), other.v_.begin(), other.v_.end());
- }
-
-
- template <typename T, typename R>
- typename median_few<T,R>::result
- median_few<T,R>::to_result() const
- {
- mln_precondition(is_valid());
- std::sort(v_.begin(), v_.end());
- // indices 0 1 2 => size = 3 => mid = 1
- // 0 1 => size = 2 => mid = 0
- unsigned mid = (v_.size() - 1) / 2;
- if (v_.size() % 2)
- return v_[mid];
- else
- return (R(v_[mid]) + R(v_[mid + 1])) / 2;
- }
-
- template <typename T, typename R>
- bool
- median_few<T,R>::is_valid() const
- {
- return v_.size() != 0;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace mln::accu::stat
-
- } // end of namespace mln::accu
-
-} // end of namespace mln
-
-#endif // ! MLN_ACCU_STAT_MEDIAN_FEW_HH
diff --git a/milena/mln/world/kn/accu/median_few.hh b/milena/mln/world/kn/accu/median_few.hh
new file mode 100644
index 0000000..31dfd68
--- /dev/null
+++ b/milena/mln/world/kn/accu/median_few.hh
@@ -0,0 +1,152 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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 MLN_WORLD_KN_ACCU_MEDIAN_FEW_HH
+# define MLN_WORLD_KN_ACCU_MEDIAN_FEW_HH
+
+/// \file
+///
+/// \brief Define a median accumulator class to be used with few
+/// values.
+
+# include <iostream>
+# include <vector>
+# include <algorithm>
+
+# include <mln/trait/routine/mean.hh>
+# include <mln/accu/internal/base.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace kn
+ {
+
+ namespace accu
+ {
+
+ /// \brief Define a median accumulator class to be used with few
+ /// values.
+ template <typename T,
+ typename R = mln_trait_routine_mean(2,T) >
+ struct median_few
+ : public mln::accu::internal::base< R, median_few<T,R> >
+ {
+ typedef T argument;
+ typedef R result;
+
+ median_few();
+
+ void reserve(unsigned n);
+ void init();
+
+ void take(const argument& v);
+ void take(const median_few<T,R>& other);
+ // nota bene: no possible untake with this accumulator
+
+ result to_result() const;
+
+ bool is_valid() const;
+
+ protected:
+
+ mutable std::vector<argument> v_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename R>
+ median_few<T,R>::median_few()
+ {
+ init();
+ }
+
+ template <typename T, typename R>
+ void
+ median_few<T,R>::reserve(unsigned n)
+ {
+ v_.reserve(n);
+ }
+
+ template <typename T, typename R>
+ void
+ median_few<T,R>::init()
+ {
+ v_.clear();
+ }
+
+ template <typename T, typename R>
+ void
+ median_few<T,R>::take(const argument& v)
+ {
+ v_.push_back(v);
+ }
+
+ template <typename T, typename R>
+ void
+ median_few<T,R>::take(const median_few<T,R>& other)
+ {
+ v_.insert(v_.end(), other.v_.begin(), other.v_.end());
+ }
+
+
+ template <typename T, typename R>
+ typename median_few<T,R>::result
+ median_few<T,R>::to_result() const
+ {
+ mln_precondition(is_valid());
+ std::sort(v_.begin(), v_.end());
+ // indices 0 1 2 => size = 3 => mid = 1
+ // 0 1 => size = 2 => mid = 0
+ unsigned mid = (v_.size() - 1) / 2;
+ if (v_.size() % 2)
+ return v_[mid];
+ else
+ return (R(v_[mid]) + R(v_[mid + 1])) / 2;
+ }
+
+ template <typename T, typename R>
+ bool
+ median_few<T,R>::is_valid() const
+ {
+ return v_.size() != 0;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::kn::accu
+
+ } // end of namespace mln::world::kn
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_KN_ACCU_MEDIAN_FEW_HH
diff --git a/milena/mln/world/kn/hqueue.hh b/milena/mln/world/kn/hqueue.hh
new file mode 100644
index 0000000..dc2b365
--- /dev/null
+++ b/milena/mln/world/kn/hqueue.hh
@@ -0,0 +1,160 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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 MLN_WORLD_KN_HQUEUE_HH
+# define MLN_WORLD_KN_HQUEUE_HH
+
+/// \file
+/// \brief Class for hierarchical queues.
+
+
+# include <iostream>
+# include <vector>
+# include <mln/world/kn/internal/queue.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace kn
+ {
+
+ /// \internal
+ /// \brief Class for hierarchical queues.
+ template <typename T, typename P>
+ class hqueue
+ {
+ public:
+ hqueue();
+ hqueue(const value::interval<P>& inter);
+ hqueue(const P& first, const P& last);
+
+ unsigned nelements() const;
+
+ bool is_empty() const;
+ bool is_empty_at(const P& bucket) const;
+
+ void push(const T& t, const P& bucket);
+ T pop(const P& bucket);
+
+ // FIXME: add some reserve strategies...
+
+ private:
+ std::vector< internal::queue_<T> > v_;
+ value::interval<P> inter_;
+ unsigned n_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename T, typename P>
+ hqueue<T,P>::hqueue()
+ {
+ n_ = 0;
+ }
+
+ template <typename T, typename P>
+ hqueue<T,P>::hqueue(const value::interval<P>& inter)
+ {
+ v_.resize(inter.nelements());
+ inter_ = inter;
+ n_ = 0;
+ }
+
+ template <typename T, typename P>
+ hqueue<T,P>::hqueue(const P& first, const P& last)
+ {
+ v_.resize(inter_.nelements());
+ inter_ = value::interval<P>(first, last);
+ n_ = 0;
+ }
+
+ template <typename T, typename P>
+ unsigned
+ hqueue<T,P>::nelements() const
+ {
+ return n_;
+ }
+
+ template <typename T, typename P>
+ bool
+ hqueue<T,P>::is_empty_at(const P& bucket) const
+ {
+ unsigned i = inter_.index_of(bucket);
+ mln_precondition(i < v_.size());
+ return v_[i].is_empty();
+ }
+
+ template <typename T, typename P>
+ bool
+ hqueue<T,P>::is_empty() const
+ {
+ return n_ == 0;
+ }
+
+ template <typename T, typename P>
+ void
+ hqueue<T,P>::push(const T& t, const P& bucket)
+ {
+ unsigned i = inter_.index_of(bucket);
+ mln_precondition(i < v_.size());
+ v_[i].push(t);
+ }
+
+ template <typename T, typename P>
+ T
+ hqueue<T,P>::pop(const P& bucket)
+ {
+ mln_precondition(! is_empty_at(bucket));
+ unsigned i = inter_.index_of(bucket);
+ mln_precondition(i < v_.size());
+ return v_[i].pop();
+ }
+
+ // template <typename T, typename P>
+ // std::ostream&
+ // operator<<(std::ostream& ostr, const hqueue<T,P>& q)
+ // {
+ // unsigned n = q.size();
+ // ostr << '(';
+ // for (unsigned i = 0; i < n; ++i)
+ // ostr << q.v_[i] << (i + 1 == n ? "" : ", ");
+ // return ostr << ')';
+ // }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::kn
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_KN_HQUEUE_HH
diff --git a/milena/mln/world/kn/internal/hqueue.hh b/milena/mln/world/kn/internal/hqueue.hh
deleted file mode 100644
index fe29376..0000000
--- a/milena/mln/world/kn/internal/hqueue.hh
+++ /dev/null
@@ -1,165 +0,0 @@
-// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project 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 MLN_WORLD_KN_INTERNAL_HQUEUE_HH
-# define MLN_WORLD_KN_INTERNAL_HQUEUE_HH
-
-/// \file
-/// \brief Class for hierarchical queues.
-
-
-# include <iostream>
-# include <vector>
-# include <mln/world/kn/internal/queue.hh>
-
-namespace mln
-{
-
- namespace world
- {
-
- namespace kn
- {
-
- namespace internal
- {
-
- /// \internal
- /// \brief Class for hierarchical queues.
- template <typename T, typename P>
- class hqueue
- {
- public:
- hqueue();
- hqueue(const value::interval<P>& inter);
- hqueue(const P& first, const P& last);
-
- unsigned nelements() const;
-
- bool is_empty() const;
- bool is_empty_at(const P& bucket) const;
-
- void push(const T& t, const P& bucket);
- T pop(const P& bucket);
-
- // FIXME: add some reserve strategies...
-
- private:
- std::vector< internal::queue_<T> > v_;
- value::interval<P> inter_;
- unsigned n_;
- };
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename T, typename P>
- hqueue<T,P>::hqueue()
- {
- n_ = 0;
- }
-
- template <typename T, typename P>
- hqueue<T,P>::hqueue(const value::interval<P>& inter)
- {
- v_.resize(inter.nelements());
- inter_ = inter;
- n_ = 0;
- }
-
- template <typename T, typename P>
- hqueue<T,P>::hqueue(const P& first, const P& last)
- {
- v_.resize(inter_.nelements());
- inter_ = value::interval<P>(first, last);
- n_ = 0;
- }
-
- template <typename T, typename P>
- unsigned
- hqueue<T,P>::nelements() const
- {
- return n_;
- }
-
- template <typename T, typename P>
- bool
- hqueue<T,P>::is_empty_at(const P& bucket) const
- {
- unsigned i = inter_.index_of(bucket);
- mln_precondition(i < v_.size());
- return v_[i].is_empty();
- }
-
- template <typename T, typename P>
- bool
- hqueue<T,P>::is_empty() const
- {
- return n_ == 0;
- }
-
- template <typename T, typename P>
- void
- hqueue<T,P>::push(const T& t, const P& bucket)
- {
- unsigned i = inter_.index_of(bucket);
- mln_precondition(i < v_.size());
- v_[i].push(t);
- }
-
- template <typename T, typename P>
- T
- hqueue<T,P>::pop(const P& bucket)
- {
- mln_precondition(! is_empty_at(bucket));
- unsigned i = inter_.index_of(bucket);
- mln_precondition(i < v_.size());
- return v_[i].pop();
- }
-
- // template <typename T, typename P>
- // std::ostream&
- // operator<<(std::ostream& ostr, const hqueue<T,P>& q)
- // {
- // unsigned n = q.size();
- // ostr << '(';
- // for (unsigned i = 0; i < n; ++i)
- // ostr << q.v_[i] << (i + 1 == n ? "" : ", ");
- // return ostr << ')';
- // }
-
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace mln::world::kn::internal
-
- } // end of namespace mln::world::kn
-
- } // end of namespace mln::world
-
-} // end of namespace mln
-
-#endif // ! MLN_WORLD_KN_INTERNAL_HQUEUE_HH
--
1.7.2.5