diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-03-22 15:12:17 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-03-22 15:12:17 +0000 |
commit | b69cc713465675a9bab998cb0688eb91390978a6 (patch) | |
tree | 09c8d601c45b9a6c143beaa1c495a74cffa8b3a6 /src | |
parent | 1f3716292673a56413d3501b4b98b54416d193ed (diff) |
code review : use std::begin, std::end and boost::size
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cechcomplex_vincent@3305 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: e59699bc13ae66476001ef5f648759fef68ee76a
Diffstat (limited to 'src')
-rw-r--r-- | src/Cech_complex/include/gudhi/Cech_complex.h | 12 | ||||
-rw-r--r-- | src/common/include/gudhi/distance_functions.h | 9 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/Cech_complex/include/gudhi/Cech_complex.h b/src/Cech_complex/include/gudhi/Cech_complex.h index 8b1a9221..bfad8b77 100644 --- a/src/Cech_complex/include/gudhi/Cech_complex.h +++ b/src/Cech_complex/include/gudhi/Cech_complex.h @@ -48,8 +48,8 @@ namespace cech_complex { * \tparam SimplicialComplexForProximityGraph furnishes `Vertex_handle` and `Filtration_value` type definition required * by `Gudhi::Proximity_graph`. * - * \tparam ForwardPointRange furnishes `.size()`, `.begin()` and `.end()` methods, and a `const_iterator` type - * definition. + * \tparam ForwardPointRange must be a range for which `std::begin()` and `std::end()` methods return input + * iterators on a point. `std::begin()` and `std::end()` methods are also required for a point. */ template<typename SimplicialComplexForProximityGraph, typename ForwardPointRange> class Cech_complex { @@ -64,8 +64,8 @@ class Cech_complex { * @param[in] points Range of points. * @param[in] max_radius Maximal radius value. * - * \tparam ForwardPointRange must be a range for which `.size()`, `.begin()` and `.end()` methods return input - * iterators on a point. `.begin()` and `.end()` methods are required for a point. + * \tparam ForwardPointRange must be a range for which `std::begin()` and `std::end()` methods return input + * iterators on a point. `std::begin()` and `std::end()` methods are also required for a point. * */ Cech_complex(const ForwardPointRange& points, Filtration_value max_radius) @@ -107,9 +107,9 @@ class Cech_complex { * @exception std::out_of_range In debug mode, if point position in the range is out. */ typename ForwardPointRange::const_iterator point_iterator(std::size_t vertex) const { - GUDHI_CHECK((point_cloud_.begin() + vertex) < point_cloud_.end(), + GUDHI_CHECK((std::begin(point_cloud_) + vertex) < std::end(point_cloud_), std::out_of_range("Cech_complex::point - simplicial complex is not empty")); - return (point_cloud_.begin() + vertex); + return (std::begin(point_cloud_) + vertex); } private: diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index 429a5fa7..20b04000 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -28,6 +28,7 @@ #include <gudhi/Miniball.hpp> #include <boost/range/metafunctions.hpp> +#include <boost/range/size.hpp> #include <cmath> // for std::sqrt #include <type_traits> // for std::decay @@ -74,13 +75,11 @@ class Euclidean_distance { * The points are assumed to have the same dimension. */ class Minimal_enclosing_ball_radius { public: - // boost::range_value is not SFINAE-friendly so we cannot use it in the return type template< typename Point > typename std::iterator_traits<typename boost::range_iterator<Point>::type>::value_type operator()(const Point& p1, const Point& p2) const { return Euclidean_distance()(p1, p2) / 2.; } - // boost::range_value is not SFINAE-friendly so we cannot use it in the return type template< typename Point_cloud, typename Point_iterator = typename boost::range_const_iterator<Point_cloud>::type, typename Point= typename std::iterator_traits<Point_iterator>::value_type, @@ -90,11 +89,11 @@ class Minimal_enclosing_ball_radius { operator()(const Point_cloud& point_cloud) const { using Min_sphere = Miniball::Miniball<Miniball::CoordAccessor<Point_iterator, Coordinate_iterator>>; - Min_sphere ms(point_cloud.begin()->end() - point_cloud.begin()->begin(), point_cloud.begin(),point_cloud.end()); + Min_sphere ms(boost::size(*point_cloud.begin()), point_cloud.begin(),point_cloud.end()); #ifdef DEBUG_TRACES std::cout << "Minimal_enclosing_ball_radius = " << std::sqrt(ms.squared_radius()) << " | nb points = " - << point_cloud.end() - point_cloud.begin() << " | dimension = " - << point_cloud.begin()->end() - point_cloud.begin()->begin() << std::endl; + << boost::size(point_cloud) << " | dimension = " + << boost::size(*point_cloud.begin()) << std::endl; #endif // DEBUG_TRACES return std::sqrt(ms.squared_radius()); |