summaryrefslogtreecommitdiff
path: root/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
diff options
context:
space:
mode:
authorglisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-10-05 14:17:38 +0000
committerglisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-10-05 14:17:38 +0000
commit37f590e0d63055e5927c77d2ffa9f3dd8271a5c6 (patch)
tree90114e022cd5f33d200f049e04ba34a36728c4da /src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
parentd453e0244c602d816db3d25882a65b69012ccb64 (diff)
Use boost static_vector instead of std::vector in the boundary iterator of Simplex_tree.
The size can never grow very large (bounded by the dimension, which is bounded by the log of the number of simplices) and this avoids a lot of dynamic memory handling. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@825 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 9f6bdc1ed7bae4c44432a05278a719f9aee26b99
Diffstat (limited to 'src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h')
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
index 8cf5a67e..f83f5ea8 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
@@ -24,6 +24,10 @@
#define SIMPLEX_TREE_ITERATORS_H_
#include <boost/iterator/iterator_facade.hpp>
+#include <boost/version.hpp>
+#if BOOST_VERSION >= 105600
+# include <boost/container/static_vector.hpp>
+#endif
#include <vector>
@@ -131,8 +135,7 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade<
}
Siblings * for_sib = sib_;
- for (typename std::vector<Vertex_handle>::reverse_iterator rit = suffix_
- .rbegin(); rit != suffix_.rend(); ++rit) {
+ for (auto rit = suffix_.rbegin(); rit != suffix_.rend(); ++rit) {
sh_ = for_sib->find(*rit);
for_sib = sh_->second.children();
}
@@ -142,9 +145,18 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade<
sib_ = sib_->oncles();
}
+ // Most of the storage should be moved to the range, iterators should be light.
Vertex_handle last_; // last vertex of the simplex
Vertex_handle next_; // next vertex to push in suffix_
+#if BOOST_VERSION >= 105600
+ // 40 seems a conservative bound on the dimension of a Simplex_tree for now,
+ // as it would not fit on the biggest hard-drive.
+ boost::container::static_vector<Vertex_handle, 40> suffix_;
+ // static_vector still has some overhead compared to a trivial hand-made
+ // version using std::aligned_storage, or compared to making suffix_ static.
+#else
std::vector<Vertex_handle> suffix_;
+#endif
Siblings * sib_; // where the next search will start from
Simplex_handle sh_; // current Simplex_handle in the boundary
SimplexTree * st_; // simplex containing the simplicial complex