From 16ff459809374b1d8616a81dda2340c7f3942912 Mon Sep 17 00:00:00 2001 From: glisse Date: Sat, 11 Jul 2015 14:35:23 +0000 Subject: Clean-ups Use vector instead of list. Use emplace more. Use std::max. Some const. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@701 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 275156e94b4c9900c0af43ed7b74c7bff40bd7fd --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 35 +++++++--------------- .../gudhi/Simplex_tree/Simplex_tree_siblings.h | 11 ++++--- 2 files changed, 15 insertions(+), 31 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 61e07f84..2916ca97 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -881,40 +881,25 @@ class Simplex_tree { static void intersection(std::vector >& intersection, Dictionary_it begin1, Dictionary_it end1, Dictionary_it begin2, Dictionary_it end2, - Filtration_value filtration) { + Filtration_value filtration_) { if (begin1 == end1 || begin2 == end2) return; // ----->> while (true) { if (begin1->first == begin2->first) { - intersection.push_back(std::pair(begin1->first, - Node(NULL, - maximum(begin1->second.filtration(), - begin2->second.filtration(), filtration)))); - ++begin1; - ++begin2; - if (begin1 == end1 || begin2 == end2) + Filtration_value filt = (std::max)({begin1->second.filtration(), begin2->second.filtration(), filtration_}); + intersection.push_back(std::pair(begin1->first, Node(NULL, filt))); + if (++begin1 == end1 || ++begin2 == end2) + return; // ----->> + } else if (begin1->first < begin2->first) { + if (++begin1 == end1) + return; + } else /* begin1->first > begin2->first */ { + if (++begin2 == end2) return; // ----->> - } else { - if (begin1->first < begin2->first) { - ++begin1; - if (begin1 == end1) - return; - } else { - ++begin2; - if (begin2 == end2) - return; // ----->> - } } } } - /** Maximum over 3 values.*/ - static Filtration_value maximum(Filtration_value a, Filtration_value b, - Filtration_value c) { - Filtration_value max = (a < b) ? b : a; - return ((max < c) ? c : max); - } - public: /** \brief Write the hasse diagram of the simplicial complex in os. * diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h index 977fafa1..d6cbacaa 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h @@ -77,8 +77,8 @@ class Simplex_tree_siblings { parent_(parent), members_(boost::container::ordered_unique_range, members.begin(), members.end()) { - for (auto map_it = members_.begin(); map_it != members_.end(); map_it++) { - map_it->second.assign_children(this); + for (auto& map_el : members_) { + map_el.second.assign_children(this); } } @@ -96,8 +96,7 @@ class Simplex_tree_siblings { return; } if (sh == members_.end()) { - members_.insert( - std::pair(v, Node(this, filtration_value))); + members_.emplace(v, Node(this, filtration_value)); return; } } @@ -110,7 +109,7 @@ class Simplex_tree_siblings { return oncles_; } - Vertex_handle parent() { + Vertex_handle parent() const { return parent_; } @@ -118,7 +117,7 @@ class Simplex_tree_siblings { return members_; } - size_t size() { + size_t size() const { return members_.size(); } -- cgit v1.2.3