summaryrefslogtreecommitdiff
path: root/src/Simplex_tree
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-08-28 07:51:11 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-08-28 07:51:11 +0000
commit7f94efd0e40f9fe15d9131643c19e285fbf75d6e (patch)
tree08148c15fd0f5afb888f2022655f6490818f307e /src/Simplex_tree
parentaf065fc6d2d4771485118bb5122b3d5203b367ed (diff)
Update children on move
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/simplex_tree_fix_vincent@3835 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c9596c534477e6fe098c406307dc8930f71e3a30
Diffstat (limited to 'src/Simplex_tree')
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h
index 8e0ddf75..69ed5e13 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h
@@ -334,7 +334,9 @@ class Simplex_tree {
#ifdef DEBUG_TRACES
std::cout << "Simplex_tree move constructor" << std::endl;
#endif // DEBUG_TRACES
+ // Need to update root members (children->oncles and children need to point on the new root pointer)
for (auto& map_el : root_.members()) {
+ // children->oncles update after the move
if (map_el.second.children()->oncles() == &(simplex_source.root_))
// reset with the moved root_ pointer value
map_el.second.children()->oncles_ = &root_;
@@ -342,6 +344,10 @@ class Simplex_tree {
// if simplex is of dimension 0, oncles_ shall be nullptr
GUDHI_CHECK(map_el.second.children()->oncles_ == nullptr,
std::invalid_argument("Simplex_tree move constructor from an invalid Simplex_tree"));
+ // children update after the move
+ if (map_el.second.children() == &(simplex_source.root_))
+ // reset with the moved root_ pointer value
+ map_el.second.assign_children(&root_);
}
// just need to set dimension_ on source to make it available again
// (filtration_vect_ and members are already set from the move)
@@ -393,7 +399,9 @@ class Simplex_tree {
std::swap( filtration_vect_, simplex_source.filtration_vect_ );
std::swap( dimension_, simplex_source.dimension_ );
+ // Need to update root members (children->oncles and children need to point on the new root pointer)
for (auto& map_el : root_.members()) {
+ // children->oncles update after the move
if (map_el.second.children()->oncles() == &(simplex_source.root_))
// reset with the moved root_ pointer value
map_el.second.children()->oncles_ = &root_;
@@ -401,6 +409,10 @@ class Simplex_tree {
// if simplex is of dimension 0, oncles_ shall be nullptr
GUDHI_CHECK(map_el.second.children()->oncles_ == nullptr,
std::invalid_argument("Simplex_tree move constructor from an invalid Simplex_tree"));
+ // children update after the move
+ if (map_el.second.children() == &(simplex_source.root_))
+ // reset with the moved root_ pointer value
+ map_el.second.assign_children(&root_);
}
}
return *this;