From a61d6e02a44f27e9420abb5a97b3b150550b7e58 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 4 Jul 2017 14:54:21 +0200 Subject: [PATCH] Fix Point_set_3::remove(const Index&) and add test --- Point_set_3/include/CGAL/Point_set_3.h | 3 +-- Point_set_3/test/Point_set_3/point_set_test.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Point_set_3/include/CGAL/Point_set_3.h b/Point_set_3/include/CGAL/Point_set_3.h index b18e939493e..c03bbf0ffdb 100644 --- a/Point_set_3/include/CGAL/Point_set_3.h +++ b/Point_set_3/include/CGAL/Point_set_3.h @@ -581,8 +581,7 @@ public: */ void remove (const Index& index) { - std::swap (index, *(end() - 1)); - ++ m_nb_removed; + remove (m_indices.begin() + index); } diff --git a/Point_set_3/test/Point_set_3/point_set_test.cpp b/Point_set_3/test/Point_set_3/point_set_test.cpp index a0208f97d4e..14bfa12d0c9 100644 --- a/Point_set_3/test/Point_set_3/point_set_test.cpp +++ b/Point_set_3/test/Point_set_3/point_set_test.cpp @@ -74,6 +74,12 @@ int main (int, char**) point_set.collect_garbage(); test (!(point_set.has_garbage()), "point set shouldn't have garbage."); + point_set.remove (*(point_set.begin())); + + test (point_set.has_garbage(), "point set should have garbage."); + point_set.collect_garbage(); + test (!(point_set.has_garbage()), "point set shouldn't have garbage."); + test (!(point_set.has_property_map ("color")), "point set shouldn't have colors."); Point_set::Property_map color_prop; bool garbage;