diff options
Diffstat (limited to 'src/common/include')
-rw-r--r-- | src/common/include/gudhi/Null_output_iterator.h | 48 | ||||
-rw-r--r-- | src/common/include/gudhi/distance_functions.h | 11 |
2 files changed, 53 insertions, 6 deletions
diff --git a/src/common/include/gudhi/Null_output_iterator.h b/src/common/include/gudhi/Null_output_iterator.h new file mode 100644 index 00000000..42e6e449 --- /dev/null +++ b/src/common/include/gudhi/Null_output_iterator.h @@ -0,0 +1,48 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Marc Glisse + * + * Copyright (C) 2017 INRIA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef NULL_OUTPUT_ITERATOR_H_ +#define NULL_OUTPUT_ITERATOR_H_ + +#include <iterator> + +namespace Gudhi { + +/** An output iterator that ignores whatever it is given. */ +struct Null_output_iterator { + typedef std::output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + Null_output_iterator& operator++() {return *this;} + Null_output_iterator operator++(int) {return *this;} + struct proxy { + template<class T> + proxy& operator=(T&&){return *this;} + }; + proxy operator*()const{return {};} +}; +} // namespace Gudhi + +#endif // NULL_OUTPUT_ITERATOR_H_ diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index 7f33a804..f6e2ab5a 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -27,6 +27,8 @@ #include <type_traits> // for std::decay #include <iterator> // for std::begin, std::end +namespace Gudhi { + /** @file * @brief Global distance functions */ @@ -35,7 +37,7 @@ * have the same dimension. */ class Euclidean_distance { public: - template< typename Point > + template< typename Point > auto operator()(const Point& p1, const Point& p2) const -> typename std::decay<decltype(*std::begin(p1))>::type { auto it1 = p1.begin(); auto it2 = p2.begin(); @@ -46,11 +48,8 @@ class Euclidean_distance { } return std::sqrt(dist); } - template< typename T > - T operator() ( const std::pair< T,T >& f , const std::pair< T,T >& s ) - { - return sqrt( (f.first-s.first)*(f.first-s.first) + (f.second-s.second)*(f.second-s.second) ); - } }; +} // namespace Gudhi + #endif // DISTANCE_FUNCTIONS_H_ |