
https://svn.lrde.epita.fr/svn/oln/trunk/milena Th�o, si tu veux faire la r�vision 2000, c'est le moment ! ;-) Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Have mln:p_set be able to erase its elements. * mln/core/p_set.hh (mln::p_set<P>::remove): Enable this method. * mln/core/internal/set_of.hh (mln::internal::set_of_<E>::s_): Make it protected. (mln::internal::set_of_<E>::remove): Use std::set::erase instead of std::remove. * tests/core/p_set.cc: Exercise mln::p_set<P>::remove. mln/core/internal/set_of.hh | 6 +++--- mln/core/p_set.hh | 29 +++++++++++++++-------------- tests/core/p_set.cc | 7 +++++++ 3 files changed, 25 insertions(+), 17 deletions(-) Index: tests/core/p_set.cc --- tests/core/p_set.cc (revision 1998) +++ tests/core/p_set.cc (working copy) @@ -50,7 +50,14 @@ 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; + ps.remove(make::point2d(4, 2)); + mln_assertion(ps.npoints() == 2); + + 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: mln/core/internal/set_of.hh --- mln/core/internal/set_of.hh (revision 1998) +++ mln/core/internal/set_of.hh (working copy) @@ -147,13 +147,14 @@ */ mutable std::vector<E> v_; + protected: /*! \brief Set of elements. * * This structure is always up-to-date w.r.t. the set contents. */ std::set<E> s_; - + private: /*! \brief Update \a v_ from \a s_. * * FIXME: explain. @@ -206,8 +207,7 @@ set_of_<E>& set_of_<E>::remove(const E& elt) { - // FIXME : doesn't compile - std::remove(s_.begin(), s_.end(), elt); + s_.erase(elt); if (needs_update_ == false) needs_update_ = true; return internal::force_exact< set_of_<E> >(*this); Index: mln/core/p_set.hh --- mln/core/p_set.hh (revision 1998) +++ mln/core/p_set.hh (working copy) @@ -78,9 +78,8 @@ /// Insert a point \p p. p_set<P>& insert(const P& p); - // FIXME : doesn't compile - // /// Remove a point \p p. - // p_set<P>& remove(P& p); + /// Remove a point \p p. + p_set<P>& remove(const P& p); /// Return the \p i-th point. const P& operator[](unsigned i) const; @@ -132,17 +131,19 @@ 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 + p_set<P>& + p_set<P>::remove(const P& p) + { + this->super_::remove(p); + // Rebuild the bounding box. + bb_.init(); + for (typename std::set<P>::const_iterator i = this->s_.begin(); + i != this->s_.end(); ++i) + bb_.take(*i); + return *this; + } template <typename P> inline