From f48bc4bc46bfa27667ef61b909413d6f7e117379 Mon Sep 17 00:00:00 2001 From: matekelemen Date: Sun, 20 Oct 2024 17:53:08 +0200 Subject: [PATCH 1/3] remove unused members requiring nonexistent EqualKeyTo --- kratos/containers/global_pointers_vector.h | 15 --------------- kratos/containers/pointer_vector.h | 18 +++++------------- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/kratos/containers/global_pointers_vector.h b/kratos/containers/global_pointers_vector.h index bb30ed3bb1f6..5faf0fe36474 100644 --- a/kratos/containers/global_pointers_vector.h +++ b/kratos/containers/global_pointers_vector.h @@ -199,21 +199,6 @@ class GlobalPointersVector final return mData[i]; } - /** - * @brief Equality comparison operator to check if two GlobalPointersVector objects are equal. - * @details This function checks if the sizes are equal and then compares the elements for equality - * using the EqualKeyTo() function. - * @param r The GlobalPointersVector to compare with. - * @return True if the containers are equal, false otherwise. - */ - bool operator==(const GlobalPointersVector& r) const // nothrow - { - if (size() != r.size()) - return false; - else - return std::equal(mData.begin(), mData.end(), r.mData.begin(), this->EqualKeyTo()); - } - ///@} ///@name Operations ///@{ diff --git a/kratos/containers/pointer_vector.h b/kratos/containers/pointer_vector.h index 3d4f988986a2..71175e469507 100644 --- a/kratos/containers/pointer_vector.h +++ b/kratos/containers/pointer_vector.h @@ -2,14 +2,14 @@ // ' / __| _` | __| _ \ __| // . \ | ( | | ( |\__ ` // _|\_\_| \__,_|\__|\___/ ____/ -// Multi-Physics +// Multi-Physics // -// License: BSD License +// License: BSD License // Kratos default license: kratos/license.txt // // Main authors: Pooyan Dadvand // Riccardo Rossi -// +// // @@ -154,14 +154,6 @@ class PointerVector final return mData[i]; } - bool operator==( const PointerVector& r ) const // nothrow - { - if( size() != r.size() ) - return false; - else - return std::equal(mData.begin(), mData.end(), r.mData.begin(), this->EqualKeyTo()); - } - ///@} ///@name Operations ///@{ @@ -278,7 +270,7 @@ class PointerVector final } template - void emplace_back(Args&&... args) + void emplace_back(Args&&... args) { mData.emplace_back(std::forward(args)...); } @@ -520,4 +512,4 @@ inline std::ostream& operator << (std::ostream& rOStream, } // namespace Kratos. -#endif // KRATOS_POINTER_VECTOR_SET_H_INCLUDED defined +#endif // KRATOS_POINTER_VECTOR_SET_H_INCLUDED defined From cc2e1dd59731aff67d10a27edb66deaf4e3c9d39 Mon Sep 17 00:00:00 2001 From: matekelemen Date: Thu, 24 Oct 2024 14:21:47 +0200 Subject: [PATCH 2/3] Revert "remove unused members requiring nonexistent EqualKeyTo" This reverts commit f48bc4bc46bfa27667ef61b909413d6f7e117379. --- kratos/containers/global_pointers_vector.h | 15 +++++++++++++++ kratos/containers/pointer_vector.h | 18 +++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/kratos/containers/global_pointers_vector.h b/kratos/containers/global_pointers_vector.h index 5faf0fe36474..bb30ed3bb1f6 100644 --- a/kratos/containers/global_pointers_vector.h +++ b/kratos/containers/global_pointers_vector.h @@ -199,6 +199,21 @@ class GlobalPointersVector final return mData[i]; } + /** + * @brief Equality comparison operator to check if two GlobalPointersVector objects are equal. + * @details This function checks if the sizes are equal and then compares the elements for equality + * using the EqualKeyTo() function. + * @param r The GlobalPointersVector to compare with. + * @return True if the containers are equal, false otherwise. + */ + bool operator==(const GlobalPointersVector& r) const // nothrow + { + if (size() != r.size()) + return false; + else + return std::equal(mData.begin(), mData.end(), r.mData.begin(), this->EqualKeyTo()); + } + ///@} ///@name Operations ///@{ diff --git a/kratos/containers/pointer_vector.h b/kratos/containers/pointer_vector.h index 71175e469507..3d4f988986a2 100644 --- a/kratos/containers/pointer_vector.h +++ b/kratos/containers/pointer_vector.h @@ -2,14 +2,14 @@ // ' / __| _` | __| _ \ __| // . \ | ( | | ( |\__ ` // _|\_\_| \__,_|\__|\___/ ____/ -// Multi-Physics +// Multi-Physics // -// License: BSD License +// License: BSD License // Kratos default license: kratos/license.txt // // Main authors: Pooyan Dadvand // Riccardo Rossi -// +// // @@ -154,6 +154,14 @@ class PointerVector final return mData[i]; } + bool operator==( const PointerVector& r ) const // nothrow + { + if( size() != r.size() ) + return false; + else + return std::equal(mData.begin(), mData.end(), r.mData.begin(), this->EqualKeyTo()); + } + ///@} ///@name Operations ///@{ @@ -270,7 +278,7 @@ class PointerVector final } template - void emplace_back(Args&&... args) + void emplace_back(Args&&... args) { mData.emplace_back(std::forward(args)...); } @@ -512,4 +520,4 @@ inline std::ostream& operator << (std::ostream& rOStream, } // namespace Kratos. -#endif // KRATOS_POINTER_VECTOR_SET_H_INCLUDED defined +#endif // KRATOS_POINTER_VECTOR_SET_H_INCLUDED defined From dc4d299a37d2610f9b70da7960cbcbd921ee7f92 Mon Sep 17 00:00:00 2001 From: matekelemen Date: Thu, 24 Oct 2024 14:48:53 +0200 Subject: [PATCH 3/3] implement equality comparison for containers --- kratos/containers/global_pointers_vector.h | 25 ++++++++++++---------- kratos/containers/pointer_vector.h | 24 ++++++++++++--------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/kratos/containers/global_pointers_vector.h b/kratos/containers/global_pointers_vector.h index bb30ed3bb1f6..ba04848709a0 100644 --- a/kratos/containers/global_pointers_vector.h +++ b/kratos/containers/global_pointers_vector.h @@ -200,18 +200,21 @@ class GlobalPointersVector final } /** - * @brief Equality comparison operator to check if two GlobalPointersVector objects are equal. - * @details This function checks if the sizes are equal and then compares the elements for equality - * using the EqualKeyTo() function. - * @param r The GlobalPointersVector to compare with. - * @return True if the containers are equal, false otherwise. + * @brief Equality comparison operator to check if two @å GlobalPointersVector objects are equal. + * @details This function checks if the sizes are equal and then compares the elements using @a operator==. + * @param rRhs The GlobalPointersVector to compare with. + * @return True if the containers have identical sizes and store identical items in the exact same order. */ - bool operator==(const GlobalPointersVector& r) const // nothrow - { - if (size() != r.size()) - return false; - else - return std::equal(mData.begin(), mData.end(), r.mData.begin(), this->EqualKeyTo()); + bool operator==(const GlobalPointersVector& rRhs) const noexcept + { + return this->size() == rRhs.size() && std::equal( + mData.begin(), + mData.end(), + rRhs.begin(), + [](const data_type& rLhs, const data_type& rRhs) -> bool { + return rLhs == rRhs; + } + ); } ///@} diff --git a/kratos/containers/pointer_vector.h b/kratos/containers/pointer_vector.h index 3d4f988986a2..884dd3c14ea2 100644 --- a/kratos/containers/pointer_vector.h +++ b/kratos/containers/pointer_vector.h @@ -2,14 +2,14 @@ // ' / __| _` | __| _ \ __| // . \ | ( | | ( |\__ ` // _|\_\_| \__,_|\__|\___/ ____/ -// Multi-Physics +// Multi-Physics // -// License: BSD License +// License: BSD License // Kratos default license: kratos/license.txt // // Main authors: Pooyan Dadvand // Riccardo Rossi -// +// // @@ -154,12 +154,16 @@ class PointerVector final return mData[i]; } - bool operator==( const PointerVector& r ) const // nothrow + bool operator==(const PointerVector& rRhs) const noexcept { - if( size() != r.size() ) - return false; - else - return std::equal(mData.begin(), mData.end(), r.mData.begin(), this->EqualKeyTo()); + return this->size() == rRhs.size() && std::equal( + mData.begin(), + mData.end(), + rRhs.begin(), + [](const data_type& rLhs, const data_type& rRhs) -> bool { + return rLhs == rRhs; + } + ); } ///@} @@ -278,7 +282,7 @@ class PointerVector final } template - void emplace_back(Args&&... args) + void emplace_back(Args&&... args) { mData.emplace_back(std::forward(args)...); } @@ -520,4 +524,4 @@ inline std::ostream& operator << (std::ostream& rOStream, } // namespace Kratos. -#endif // KRATOS_POINTER_VECTOR_SET_H_INCLUDED defined +#endif // KRATOS_POINTER_VECTOR_SET_H_INCLUDED defined