From 724ef989782c9357ae20a4708f9a655ab0b71d5b Mon Sep 17 00:00:00 2001 From: Anirudh Lakhanpal Date: Tue, 21 Jan 2025 23:12:12 +0530 Subject: [PATCH] avoid using c style arrays --- .../examples/Min_circle_2/min_circle_2.cpp | 8 ++++---- .../examples/Min_circle_2/min_circle_homogeneous_2.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Bounding_volumes/examples/Min_circle_2/min_circle_2.cpp b/Bounding_volumes/examples/Min_circle_2/min_circle_2.cpp index e45b00c7b87..3ccc5aeb677 100644 --- a/Bounding_volumes/examples/Min_circle_2/min_circle_2.cpp +++ b/Bounding_volumes/examples/Min_circle_2/min_circle_2.cpp @@ -4,7 +4,7 @@ #include #include - +#include typedef CGAL::Simple_cartesian K; typedef CGAL::Min_sphere_of_points_d_traits_2 Traits; typedef CGAL::Min_sphere_of_spheres_d Min_circle; @@ -14,14 +14,14 @@ int main( int, char**) { const int n = 100; - Point P[n]; + std::vector P(n); CGAL::Random r; // random number generator for ( int i = 0; i < n; ++i){ - P[ i] = Point(r.get_double(), r.get_double()); + P.at(i) = Point(r.get_double(), r.get_double()); } - Min_circle mc( P, P+n); + Min_circle mc( P.begin(), P.begin() + n); Min_circle::Cartesian_const_iterator ccib = mc.center_cartesian_begin(), ccie = mc.center_cartesian_end(); std::cout << "center:"; diff --git a/Bounding_volumes/examples/Min_circle_2/min_circle_homogeneous_2.cpp b/Bounding_volumes/examples/Min_circle_2/min_circle_homogeneous_2.cpp index 238887de2e4..8ca9d53e4eb 100644 --- a/Bounding_volumes/examples/Min_circle_2/min_circle_homogeneous_2.cpp +++ b/Bounding_volumes/examples/Min_circle_2/min_circle_homogeneous_2.cpp @@ -2,7 +2,7 @@ #include #include #include - +#include #include // typedefs @@ -16,15 +16,15 @@ int main( int, char**) { const int n = 100; - Point P[n]; + std::vector P(n); for ( int i = 0; i < n; ++i){ - P[i] = Point( (i%2 == 0 ? i : -i), 0, 1); + P.at(i) = Point( (i%2 == 0 ? i : -i), 0, 1); // (0,0), (-1,0), (2,0), (-3,0), ... } - Min_circle mc1( P, P+n, false); // very slow - Min_circle mc2( P, P+n, true); // fast + Min_circle mc1( P.begin(), P.begin() + n, false); // very slow + Min_circle mc2( P.begin(), P.begin() +n, true); // fast CGAL::IO::set_pretty_mode( std::cout); std::cout << mc2;