2040: Fix priority queue-based point sets.

https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Fix priority queue-based point sets. These problems were spotted using TESTS_CXXFLAGS_DEBUG. * mln/core/p_priority_queue.hh: (mln::p_priority_queue<P, T>::queue_map_t): New typedef. Use it... (mln::p_priority_queue<P, T>::q_): ...here, and fix the type of this member. (mln::p_priority_queue<P, T>): Adjust users. * mln/core/p_priority_queue_fast.hh (mln::p_priority_queue_fast<P, T>::queue_map_t): New typedef. Use it... (mln::p_priority_queue_fast<P, T>::q_): ...here, and fix the type of this member. (mln::p_priority_queue_fast<P, T>): Adjust users. * tests/tests.mk (TESTS_CXXFLAGS_DEBUG): New. mln/core/p_priority_queue.hh | 24 +++++++++++++----------- mln/core/p_priority_queue_fast.hh | 22 +++++++++++----------- tests/tests.mk | 1 + 3 files changed, 25 insertions(+), 22 deletions(-) Index: mln/core/p_priority_queue.hh --- mln/core/p_priority_queue.hh (revision 2039) +++ mln/core/p_priority_queue.hh (working copy) @@ -117,8 +117,8 @@ const P& operator[](unsigned i) const; protected: - - std::map<const T, p_queue<P> > q_; + typedef std::map<T, p_queue<P> > queue_map_t; + queue_map_t q_; mutable std::vector<P> vect_; mutable bool vect_needs_update_; @@ -150,7 +150,7 @@ vect_.clear(); vect_.reserve(npoints()); - typename std::map<T, p_queue<P> >::const_iterator it = q_.begin (); + typename queue_map_t::const_iterator it = q_.begin (); for (; it != q_.end (); ++it) std::copy((*it).second.vect().begin(), (*it).second.vect().end(), @@ -165,7 +165,7 @@ { bb_.init(); - typename std::map<T, p_queue<P> >::const_iterator it = q_.begin (); + typename queue_map_t::const_iterator it = q_.begin (); for (; it != q_.end (); ++it) for (unsigned i = 0; i < (*it).second.npoints (); ++i) @@ -179,7 +179,7 @@ bool p_priority_queue<P, T>::has(const P& p) const { - typename std::map<T, p_queue<P> >::const_iterator it = q_.begin (); + typename queue_map_t::const_iterator it = q_.begin (); for (; it != q_.end (); ++it) if ((*it).second.has (p)) @@ -192,7 +192,7 @@ bool p_priority_queue<P, T>::is_empty() const { - typename std::map<T, p_queue<P> >::const_iterator it = q_.begin (); + typename queue_map_t::const_iterator it = q_.begin (); for (; it != q_.end (); ++it) if (!(*it).second.is_empty ()) @@ -207,7 +207,7 @@ { unsigned res = 0; - typename std::map<T, p_queue<P> >::const_iterator it = q_.begin (); + typename queue_map_t::const_iterator it = q_.begin (); for (; it != q_.end (); ++it) if (!(*it).second.is_empty ()) @@ -256,7 +256,8 @@ void p_priority_queue<P, T>::pop() { - typename std::map<T, p_queue<P> >::reverse_iterator it = q_.rbegin (); + typename queue_map_t::reverse_iterator it = + q_.rbegin (); for (; it != q_.rend (); ++it) if (!(*it).second.is_empty ()) @@ -276,7 +277,8 @@ { mln_precondition(! q_.empty()); - typename std::map<T, p_queue<P> >::const_reverse_iterator it = q_.rbegin (); + typename queue_map_t::const_reverse_iterator it = + q_.rbegin (); for (; it != q_.rend (); ++it) if (!(*it).second.is_empty ()) @@ -300,7 +302,7 @@ void p_priority_queue<P, T>::clear() { - typename std::map<T, p_queue<P> >::iterator it = q_.begin (); + typename queue_map_t::iterator it = q_.begin (); for (; it != q_.end (); ++it) (*it).second.clear (); @@ -326,7 +328,7 @@ { mln_precondition(i < npoints()); - typename std::map<T, p_queue<P> >::const_reverse_iterator it = q_.rbegin (); + typename queue_map_t::const_reverse_iterator it = q_.rbegin (); unsigned cpt = 0; for (; it != q_.rend (); ++it) Index: mln/core/p_priority_queue_fast.hh --- mln/core/p_priority_queue_fast.hh (revision 2039) +++ mln/core/p_priority_queue_fast.hh (working copy) @@ -117,8 +117,8 @@ const P& operator[](unsigned i) const; protected: - - std::map<const T, p_queue_fast<P> > q_; + typedef typename std::map<T, p_queue_fast<P> > queue_map_t; + queue_map_t q_; mutable std::vector<P> vect_; mutable bool vect_needs_update_; @@ -150,7 +150,7 @@ vect_.clear(); vect_.reserve(npoints()); - typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin (); + typename queue_map_t::const_iterator it = q_.begin (); for (; it != q_.end (); ++it) std::copy((*it).second.vect().begin(), (*it).second.vect().end(), @@ -165,7 +165,7 @@ { bb_.init(); - typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin (); + typename queue_map_t::const_iterator it = q_.begin (); for (; it != q_.end (); ++it) for (unsigned i = 0; i < (*it).second.npoints (); ++i) @@ -179,7 +179,7 @@ bool p_priority_queue_fast<P, T>::has(const P& p) const { - typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin (); + typename queue_map_t::const_iterator it = q_.begin (); for (; it != q_.end (); ++it) if ((*it).second.has (p)) @@ -192,7 +192,7 @@ bool p_priority_queue_fast<P, T>::is_empty() const { - typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin (); + typename queue_map_t::const_iterator it = q_.begin (); for (; it != q_.end (); ++it) if (!(*it).second.is_empty ()) @@ -207,7 +207,7 @@ { unsigned res = 0; - typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin (); + typename queue_map_t::const_iterator it = q_.begin (); for (; it != q_.end (); ++it) if (!(*it).second.is_empty ()) @@ -256,7 +256,7 @@ void p_priority_queue_fast<P, T>::pop() { - typename std::map<T, p_queue_fast<P> >::reverse_iterator it = q_.rbegin (); + typename queue_map_t::reverse_iterator it = q_.rbegin (); for (; it != q_.rend (); ++it) if (!(*it).second.is_empty ()) @@ -276,7 +276,7 @@ { mln_precondition(! q_.empty()); - typename std::map<T, p_queue_fast<P> >::const_reverse_iterator it = q_.rbegin (); + typename queue_map_t::const_reverse_iterator it = q_.rbegin (); for (; it != q_.rend (); ++it) if (!(*it).second.is_empty ()) @@ -300,7 +300,7 @@ void p_priority_queue_fast<P, T>::clear() { - typename std::map<T, p_queue_fast<P> >::iterator it = q_.begin (); + typename queue_map_t::iterator it = q_.begin (); for (; it != q_.end (); ++it) (*it).second.clear (); @@ -326,7 +326,7 @@ { mln_precondition(i < npoints()); - typename std::map<T, p_queue_fast<P> >::const_reverse_iterator it = q_.rbegin (); + typename queue_map_t::const_reverse_iterator it = q_.rbegin (); unsigned cpt = 0; for (; it != q_.rend (); ++it) Index: tests/tests.mk --- tests/tests.mk (revision 2039) +++ tests/tests.mk (working copy) @@ -14,3 +14,4 @@ AM_CXXFLAGS = $(TESTS_CXXFLAGS) TESTS_CXXFLAGS_SPEED = @TESTS_CXXFLAGS_SPEED@ +TESTS_CXXFLAGS_DEBUG = @TESTS_CXXFLAGS_DEBUG@
participants (1)
-
Roland Levillain