summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorROUVREAU Vincent <vincent.rouvreau@inria.fr>2019-06-27 18:45:50 +0200
committerROUVREAU Vincent <vincent.rouvreau@inria.fr>2019-06-27 18:45:50 +0200
commit6aee9ea232820f3fefd3cfd8d194834c4ed9fd22 (patch)
treea49cc5626deac9b3983262beba23087fbd566bce /src
parente6676dce1b5faa2c61707968e1e0588e5c47edbf (diff)
Code review : call std::unique right after std::sort. Repetition has been removed
Diffstat (limited to 'src')
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree.h17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h
index 519703e6..9d6e50c6 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h
@@ -775,27 +775,18 @@ class Simplex_tree {
std::vector<Vertex_handle> copy;
copy.clear();
copy.insert(copy.end(), first, last);
- std::sort(std::begin(copy), std::end(copy));
+ std::sort(copy.begin(), copy.end());
+ auto last_unique = std::unique(copy.begin(), copy.end());
+ copy.erase(last_unique, copy.end());
GUDHI_CHECK_code(
for (Vertex_handle v : copy)
GUDHI_CHECK(v != null_vertex(), "cannot use the dummy null_vertex() as a real vertex");
)
- return insert_simplex_and_subfaces_sorted(copy, filtration);
+ return rec_insert_simplex_and_subfaces_sorted(root(), copy.begin(), copy.end(), filtration, 0);
}
private:
- /// Same as insert_simplex_and_subfaces but assumes that the range of vertices is sorted
- template<class ForwardVertexRange = std::initializer_list<Vertex_handle>>
- std::pair<Simplex_handle, bool> insert_simplex_and_subfaces_sorted(const ForwardVertexRange& Nsimplex,
- Filtration_value filt = 0) {
- auto first = std::begin(Nsimplex);
- auto last = std::end(Nsimplex);
- if (first == last)
- return { null_simplex(), true }; // FIXME: false would make more sense to me.
- GUDHI_CHECK(std::is_sorted(first, last), "simplex vertices listed in unsorted order");
- return rec_insert_simplex_and_subfaces_sorted(root(), first, last, filt, 0);
- }
// To insert {1,2,3,4}, we insert {2,3,4} twice, once at the root, and once below 1.
template<class ForwardVertexIterator>
std::pair<Simplex_handle, bool> rec_insert_simplex_and_subfaces_sorted(Siblings* sib,