From 46eb14219834599b247ffe8053931262927a3014 Mon Sep 17 00:00:00 2001 From: anmoreau Date: Sun, 28 Jun 2015 21:00:20 +0000 Subject: Multiple fix git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/copy_move@658 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 85d3c8664e3191911e02189cdd33bf4c022638cd --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 37 +++++++++++++++------------ 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 63671d63..e4de5571 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -522,17 +522,18 @@ bool has_children(Simplex_handle sh) { * .end() return random access iterators, with value_type * Vertex_handle. */ -template - Simplex_handle find(RandomAccessVertexRange & s) { - RandomAccessVertexRange copy = s; - sort(s.begin(), s.end()); - return find_rec(s); +template + Simplex_handle find(const InputVertexRange & s) { + std::vector copy; + for (auto v = std::begin(s); v != std::end(s); ++v ) + copy.push_back(*v); + sort(std::begin(copy), std::end(copy)); + return find_rec(copy); } private: /** recursive function of find */ - template - Simplex_handle find_rec(RandomAccessVertexRange & simplex) { + Simplex_handle find_rec(std::vector & simplex) { if (simplex.begin() == simplex.end()) return null_simplex(); @@ -561,7 +562,7 @@ template private: /** Recursively insert a simplex */ - template + template std::pair insert_simplex_rec(RandomAccessVertexRange & simplex, Filtration_value filtration) { if (simplex.empty()) { @@ -613,10 +614,12 @@ public: * The type RandomAccessVertexRange must be a range for which .begin() and * .end() return random access iterators, with 'value_type' Vertex_handle. */ template -std::pair insert_simplex(RandomAccessVertexRange & simplex, +std::pair insert_simplex(const RandomAccessVertexRange & simplex, Filtration_value filtration) { - RandomAccessVertexRange copy = simplex; - sort(copy.begin(), copy.end()); + std::vector copy; + for (auto v = std::begin(simplex); v != std::end(simplex); ++v) + copy.push_back(*v); + sort(std::begin(copy), std::end(copy)); return insert_simplex_rec(copy, filtration); } @@ -626,18 +629,20 @@ std::pair insert_simplex(RandomAccessVertexRange & simplex * @param[in] Nsimplex range of Vertex_handles, representing the vertices of the new N-simplex * @param[in] filtration the filtration value assigned to the new N-simplex. */ - template - void insert_simplex_and_subfaces(RandomAccessVertexRange& Nsimplex, + template + void insert_simplex_and_subfaces(const InputVertexRange& Nsimplex, Filtration_value filtration = 0.0) { - RandomAccessVertexRange copy(Nsimplex); - sort(copy.begin(), copy.end()); // must be sorted in increasing order + std::vector copy; + for (auto v = std::begin(Nsimplex); v != std::end(Nsimplex); ++v) + copy.push_back(*v); + sort(std::begin(copy), std::end(copy)); insert_simplex_and_subfaces_rec(copy, filtration); } private: /** Recursively insert simplex and all of its subfaces */ - template + template void insert_simplex_and_subfaces_rec(RandomAccessVertexRange & Nsimplex, Filtration_value filtration = 0.0) { -- cgit v1.2.3