diff options
-rw-r--r-- | src/Simplex_tree/include/gudhi/Simplex_tree.h | 13 | ||||
-rw-r--r-- | src/Simplex_tree/test/simplex_tree_unit_test.cpp | 10 |
2 files changed, 11 insertions, 12 deletions
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 05c493dd..a5ad6a79 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -347,18 +347,21 @@ class Simplex_tree { public: /** \brief Checks if two simplex trees are equal. */ - // TODO: constify is required to make an operator== - bool is_equal(Simplex_tree& st2) - { + bool operator==(Simplex_tree& st2) { if ((null_vertex_ != st2.null_vertex_) || (threshold_ != st2.threshold_) || (dimension_ != st2.dimension_)) return false; return rec_equal(&root_, &st2.root_); } - - /** rec_equal: Checks recursively whether or not two simplex trees are equal, using depth first search. */ + + /** \brief Checks if two simplex trees are different. */ + bool operator!=(Simplex_tree& st2) { + return (!(*this == st2)); + } + private: + /** rec_equal: Checks recursively whether or not two simplex trees are equal, using depth first search. */ bool rec_equal(Siblings* s1, Siblings* s2) { if (s1->members().size() != s2->members().size()) return false; diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index 6be6d4f3..eb3557ae 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -649,37 +649,33 @@ BOOST_AUTO_TEST_CASE(copy_move_on_simplex_tree) { st.set_dimension(3); std::cout << "Printing st - address = " << &st << std::endl; - //std::cout << st << std::endl; // Copy constructor typeST st_copy = st; std::cout << "Printing a copy of st - address = " << &st_copy << std::endl; - //std::cout << st_copy << std::endl; // Check the data are the same - BOOST_CHECK(st.is_equal(st_copy)); + BOOST_CHECK(st == st_copy); // Check there is a new simplex tree reference BOOST_CHECK(&st != &st_copy); // Move constructor typeST st_move = std::move(st); std::cout << "Printing a move of st - address = " << &st_move << std::endl; - //std::cout << st_move << std::endl; // Check the data are the same - BOOST_CHECK(st_move.is_equal(st_copy)); + BOOST_CHECK(st_move == st_copy); // Check there is a new simplex tree reference BOOST_CHECK(&st_move != &st_copy); BOOST_CHECK(&st_move != &st); typeST st_empty; // Check st has been emptied by the move - BOOST_CHECK(st.is_equal(st_empty)); + BOOST_CHECK(st == st_empty); BOOST_CHECK(st.filtration() == 0); BOOST_CHECK(st.dimension() == -1); BOOST_CHECK(st.num_simplices() == 0); BOOST_CHECK(st.num_vertices() == (size_t)0); std::cout << "Printing st once again- address = " << &st << std::endl; - //std::cout << st << std::endl; } |