diff options
author | glisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-12-22 17:41:54 +0000 |
---|---|---|
committer | glisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-12-22 17:41:54 +0000 |
commit | 13e9c4ecc222efe0ffc3588eb8f559f7cd1d761d (patch) | |
tree | 0aee1096a8d6550468ae7aa7aa425aed38333ce3 /src/Simplex_tree/include | |
parent | 0e574fc38658b23b25655991e9822fd42fff0890 (diff) |
Prettify find_simplex().
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/misc-glisse@3105 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 34ce3d49fb8f9e64df8b492b2e9091e5e0ca6be4
Diffstat (limited to 'src/Simplex_tree/include')
-rw-r--r-- | src/Simplex_tree/include/gudhi/Simplex_tree.h | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 1a6a72a3..92add101 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -530,31 +530,30 @@ class Simplex_tree { Simplex_handle find_simplex(const std::vector<Vertex_handle> & simplex) { Siblings * tmp_sib = &root_; Dictionary_it tmp_dit; - Vertex_handle last = simplex.back(); auto vi = simplex.begin(); if (Options::contiguous_vertices) { + // Equivalent to the first iteration of the normal loop GUDHI_CHECK(contiguous_vertices(), "non-contiguous vertices"); Vertex_handle v = *vi++; if(v < 0 || v >= static_cast<Vertex_handle>(root_.members_.size())) return null_simplex(); tmp_dit = root_.members_.begin() + v; - if (!has_children(tmp_dit) && v != last) { + if (vi == simplex.end()) + return tmp_dit; + if (!has_children(tmp_dit)) return null_simplex(); - } tmp_sib = tmp_dit->second.children(); } - for (; vi != simplex.end(); ++vi) { - Vertex_handle v = *vi; - tmp_dit = tmp_sib->members_.find(v); - if (tmp_dit == tmp_sib->members_.end()) { + for (;;) { + tmp_dit = tmp_sib->members_.find(*vi++); + if (tmp_dit == tmp_sib->members_.end()) return null_simplex(); - } - if (!has_children(tmp_dit) && v != last) { + if (vi == simplex.end()) + return tmp_dit; + if (!has_children(tmp_dit)) return null_simplex(); - } tmp_sib = tmp_dit->second.children(); } - return tmp_dit; } /** \brief Returns the Simplex_handle corresponding to the 0-simplex |