olena-2.0-146-gbf7a3ec Improve interface of hqueues.

* mln/util/hqueue.hh: Do not return queues directly. * mln/world/kn/compute_tree_of_shapes.hh: Update the use of hqueue. --- milena/ChangeLog | 9 ++++++++ milena/mln/util/hqueue.hh | 28 ++++++++++++------------ milena/mln/world/kn/compute_tree_of_shapes.hh | 14 ++++++------ 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 678fb09..e6c6d2e 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,14 @@ 2012-10-26 Guillaume Lazzara <z@lrde.epita.fr> + Improve interface of hqueues. + + * mln/util/hqueue.hh: Do not return queues directly. + + * mln/world/kn/compute_tree_of_shapes.hh: Update the use of + hqueue. + +2012-10-26 Guillaume Lazzara <z@lrde.epita.fr> + Add missing typedef in functions. * mln/fun/vvvv2v/max.hh, diff --git a/milena/mln/util/hqueue.hh b/milena/mln/util/hqueue.hh index 3d28b30..ab7660c 100644 --- a/milena/mln/util/hqueue.hh +++ b/milena/mln/util/hqueue.hh @@ -53,10 +53,10 @@ namespace mln unsigned size() const; - bool is_empty() const; - bool is_not_empty() const; + bool is_empty(const P& priority) const; + bool is_not_empty(const P& priority) const; - const std::queue<T>& operator[](const P& priority) const; +// const std::queue<T>& operator[](const P& priority) const; void push(const T& t, const P& priority); T pop(const P& priority); @@ -103,25 +103,25 @@ namespace mln template <typename T, typename P> bool - hqueue<T,P>::is_empty() const + hqueue<T,P>::is_empty(const P& priority) const { - return this->size() == 0; + return v_[inter_.index_of(priority)].empty() == 0; } template <typename T, typename P> bool - hqueue<T,P>::is_not_empty() const + hqueue<T,P>::is_not_empty(const P& priority) const { - return ! this->is_empty(); + return ! is_empty(priority); } - template <typename T, typename P> - const std::queue<T>& - hqueue<T,P>::operator[](const P& i) const - { - mln_precondition(i < this->size()); - return v_[head_ + i]; - } + // template <typename T, typename P> + // const std::queue<T>& + // hqueue<T,P>::operator[](const P& i) const + // { + // mln_precondition(i < this->size()); + // return v_[head_ + i]; + // } template <typename T, typename P> void diff --git a/milena/mln/world/kn/compute_tree_of_shapes.hh b/milena/mln/world/kn/compute_tree_of_shapes.hh index e503d66..6726259 100644 --- a/milena/mln/world/kn/compute_tree_of_shapes.hh +++ b/milena/mln/world/kn/compute_tree_of_shapes.hh @@ -239,7 +239,7 @@ namespace mln for (; l_ < inter_.last(); value::inc(l_)) { - if (! q[l_].empty()) + if (q.is_not_empty(l_)) { found = true; return l_; @@ -248,7 +248,7 @@ namespace mln // Avoid overflow on last element. if (l_ == inter_.last()) - if (! q[l_].empty()) + if (q.is_not_empty(l_)) { found = true; return l_; @@ -265,7 +265,7 @@ namespace mln EV l_ = lcur; for (; l_ > inter_.first(); value::dec(l_)) - if (! q[l_].empty()) + if (q.is_not_empty(l_))) { found = true; return l_; @@ -273,7 +273,7 @@ namespace mln // Avoid overflow on first element. if (l_ == inter_.first()) - if (! q[l_].empty()) + if (q.is_not_empty(l_)) { found = true; return l_; @@ -326,10 +326,10 @@ namespace mln compute_tree_of_shapes_t<I>::priority_pop(q_type& q) // modify q, and sometimes l { - if (q[lcur].empty()) + if (q.is_empty(lcur)) { EV lcur_ = level_next_to_lcur(q); // such as q[lcur_] is not empty - if (q[lcur_].empty()) + if (q.is_empty(lcur_)) std::abort(); lcur = lcur_; } @@ -385,7 +385,7 @@ namespace mln i = i + 1; done(p) = true; - if (q[lcur].empty()) + if (q.is_empty(lcur)) { std::cout << "sort: done with level " << lcur << std::endl; dsp.show(done); -- 1.7.2.5
participants (1)
-
Guillaume Lazzara