From 616d80c1208f3a14b871b0105f56ee9abd98a82c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 21 Aug 2018 08:06:31 +0000 Subject: 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 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/Simplex_tree/include/gudhi/Simplex_tree.h') 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 -- cgit v1.2.3