Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Remove unused members from containers #12767

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions kratos/containers/global_pointers_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @matekelemen it looks to me that the comparison would make sense (provided it compiles of couse)
wouldn't it be better to implement the EqualKeyTo rather than removing the method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I don't see a use case for comparing the contents of entire containers that wouldn't be possible with std::equal, but in any case, I implemented the function then.

{
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;
}
);
}

///@}
Expand Down
24 changes: 14 additions & 10 deletions kratos/containers/pointer_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
//
//


Expand Down Expand Up @@ -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;
}
);
}

///@}
Expand Down Expand Up @@ -278,7 +282,7 @@ class PointerVector final
}

template<class... Args>
void emplace_back(Args&&... args)
void emplace_back(Args&&... args)
{
mData.emplace_back(std::forward<Args>(args)...);
}
Expand Down Expand Up @@ -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
Loading