* mln/world/kn/compute_tree_of_shapes.hh: Add a missing include.
* mln/world/kn/debug/println.hh: Check value type of the input image.
* mln/world/kn/hqueue.hh: Remove from namespace internal. --- milena/ChangeLog | 11 ++ milena/mln/world/kn/compute_tree_of_shapes.hh | 1 + milena/mln/world/kn/debug/println.hh | 2 + milena/mln/world/kn/hqueue.hh | 197 ++++++++++++------------- 4 files changed, 110 insertions(+), 101 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog index d9f6a99..3c91081 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,14 @@ +2012-11-22 Guillaume Lazzara z@lrde.epita.fr + + Small fixes. + + * mln/world/kn/compute_tree_of_shapes.hh: Add a missing include. + + * mln/world/kn/debug/println.hh: Check value type of the input + image. + + * mln/world/kn/hqueue.hh: Remove from namespace internal. + 2012-11-12 Guillaume Lazzara z@lrde.epita.fr
Improve initialization of 2-faces in borders. diff --git a/milena/mln/world/kn/compute_tree_of_shapes.hh b/milena/mln/world/kn/compute_tree_of_shapes.hh index 9c686f2..90007ac 100644 --- a/milena/mln/world/kn/compute_tree_of_shapes.hh +++ b/milena/mln/world/kn/compute_tree_of_shapes.hh @@ -44,6 +44,7 @@ # include <mln/world/kn/hqueue.hh> # include <mln/util/tree_of_shapes.hh> # include <mln/world/kn/is_2_face.hh> +# include <mln/world/k2/is_primary_2_face.hh>
// FIXME: to be removed or disabled. diff --git a/milena/mln/world/kn/debug/println.hh b/milena/mln/world/kn/debug/println.hh index 6580aa5..ce31c8c 100644 --- a/milena/mln/world/kn/debug/println.hh +++ b/milena/mln/world/kn/debug/println.hh @@ -106,6 +106,8 @@ namespace mln { const I& ima = exact(ima_); const B& bbox = exact(bbox_); + typedef mln_value(I) V; + mlc_is(V,bool)::check(); mln_precondition(ima.is_valid()); mln_precondition(I::site::dim == 2); mln_precondition(bbox.is_valid()); diff --git a/milena/mln/world/kn/hqueue.hh b/milena/mln/world/kn/hqueue.hh index fe29376..dc2b365 100644 --- a/milena/mln/world/kn/hqueue.hh +++ b/milena/mln/world/kn/hqueue.hh @@ -23,8 +23,8 @@ // 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 +#ifndef MLN_WORLD_KN_HQUEUE_HH +# define MLN_WORLD_KN_HQUEUE_HH
/// \file /// \brief Class for hierarchical queues. @@ -43,118 +43,113 @@ namespace mln 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);
- /// \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;
- unsigned nelements() const; + bool is_empty() const; + bool is_empty_at(const P& bucket) 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);
- void push(const T& t, const P& bucket); - T pop(const P& bucket); + // FIXME: add some reserve strategies...
- // FIXME: add some reserve strategies... - - private: - std::vector< internal::queue_<T> > v_; - value::interval<P> inter_; - unsigned n_; - }; + 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 << ')'; - // } + 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; + }
-# endif // ! MLN_INCLUDE_ONLY + 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; + }
- } // end of namespace mln::world::kn::internal + 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
@@ -162,4 +157,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_WORLD_KN_INTERNAL_HQUEUE_HH +#endif // ! MLN_WORLD_KN_HQUEUE_HH