summaryrefslogtreecommitdiff
path: root/src/Simplex_tree/include
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-08-21 08:06:31 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-08-21 08:06:31 +0000
commit616d80c1208f3a14b871b0105f56ee9abd98a82c (patch)
tree1c5d48e9760ba64fbf43b3f50f85ed31b208e494 /src/Simplex_tree/include
parente82a7701034b4eeedd58165559bdb4f6a951565f (diff)
Copy assignment for Simplex_tree and its tests (rules of 5)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/simplex_tree_fix_vincent@3814 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4ac0e87aaef3bf29369f25b8eb0c766a6f1b395b
Diffstat (limited to 'src/Simplex_tree/include')
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h
index ee96d5a2..ca3575ba 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h
@@ -301,6 +301,7 @@ class Simplex_tree {
root_(nullptr, null_vertex_ , simplex_source.root_.members_),
filtration_vect_(),
dimension_(simplex_source.dimension_) {
+ std::cout << "copy constructor" << std::endl;
auto root_source = simplex_source.root_;
rec_copy(&root_, &root_source);
}
@@ -326,6 +327,7 @@ class Simplex_tree {
root_(std::move(old.root_)),
filtration_vect_(std::move(old.filtration_vect_)),
dimension_(std::move(old.dimension_)) {
+ std::cout << "move constructor" << std::endl;
old.dimension_ = -1;
old.root_ = Siblings(nullptr, null_vertex_);
}
@@ -338,6 +340,20 @@ class Simplex_tree {
}
}
}
+
+ /** \brief User-defined copy assignment reproduces the whole tree structure. */
+ Simplex_tree& operator= (const Simplex_tree& simplex_source)
+ {
+ std::cout << "copy assignment" << std::endl;
+ this->null_vertex_ = simplex_source.null_vertex_;
+ root_ = Siblings(nullptr, null_vertex_ , simplex_source.root_.members_);
+ this->filtration_vect_.clear();
+ this->dimension_ = simplex_source.dimension_;
+ auto root_source = simplex_source.root_;
+ rec_copy(&(this->root_), &root_source);
+ return *this;
+ }
+
/** @} */ // end constructor/destructor
private:
// Recursive deletion