From ecc6fdcd54f3124fb00a35db56c960009f7bfc57 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Nov 2008 10:08:25 +0000 Subject: [PATCH] fix resize bug --- Arrangement_on_surface_2/include/CGAL/Arr_face_map.h | 8 ++++---- Arrangement_on_surface_2/include/CGAL/Arr_vertex_map.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_face_map.h b/Arrangement_on_surface_2/include/CGAL/Arr_face_map.h index 08cb62870e3..2826e0fa9e4 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_face_map.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_face_map.h @@ -114,7 +114,7 @@ public: */ Face_handle face (const int i) const { - CGAL_precondition (i < n_faces); + CGAL_precondition((unsigned int) i < n_faces); return (rev_map[i]); } @@ -170,8 +170,8 @@ public: n_faces++; // If necessary, allocate memory for the reverse mapping. - if (rev_map.size() > n_faces) - rev_map.resize (2 * n_faces); + if (rev_map.size() < n_faces) + rev_map.resize(2 * n_faces); // Update the mapping of the newly created face. index_map[new_f] = n_faces - 1; @@ -195,7 +195,7 @@ public: // Reduce memory consumption in case the number of faces has // drastically decreased. - if (2*n_faces < rev_map.size() && + if (2*n_faces+1 < rev_map.size() && rev_map.size() / 2 >= MIN_REV_MAP_SIZE) { rev_map.resize (rev_map.size() / 2); diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_vertex_map.h b/Arrangement_on_surface_2/include/CGAL/Arr_vertex_map.h index 9871a57ac18..d768a952684 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_vertex_map.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_vertex_map.h @@ -168,7 +168,7 @@ public: n_vertices++; // If necessary, allocate memory for the reverse mapping. - if (rev_map.size() > n_vertices) + if (rev_map.size() < n_vertices) rev_map.resize (2 * n_vertices); // Update the mapping of the newly created vertex. @@ -186,7 +186,7 @@ public: n_vertices++; // If necessary, allocate memory for the reverse mapping. - if (rev_map.size() > n_vertices) + if (rev_map.size() < n_vertices) rev_map.resize (2 * n_vertices); // Update the mapping of the newly created vertex. @@ -205,7 +205,7 @@ public: // Reduce memory consumption in case the number of vertices has // drastically decreased. - if (2*n_vertices < rev_map.size() && + if (2*n_vertices+1 < rev_map.size() && rev_map.size() / 2 >= MIN_REV_MAP_SIZE) { rev_map.resize (rev_map.size() / 2);