1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:07:45 +00:00

AK: Vector use Traits<T>::equals in find

Use Traits<T>::equals for equality checking in search
functions instead of  operator==
This commit is contained in:
Muhammad Zahalqa 2020-09-06 22:49:59 +03:00 committed by Andreas Kling
parent ad3e6ef344
commit 125ea6a214

View file

@ -249,7 +249,7 @@ public:
bool contains_slow(const T& value) const
{
for (size_t i = 0; i < size(); ++i) {
if (at(i) == value)
if (Traits<T>::equals(at(i), value))
return true;
}
return false;
@ -612,18 +612,18 @@ public:
ConstIterator find(const T& value) const
{
return find([&](auto& other) { return value == other; });
return find([&](auto& other) { return Traits<T>::equals(value, other); });
}
Iterator find(const T& value)
{
return find([&](auto& other) { return value == other; });
return find([&](auto& other) { return Traits<T>::equals(value, other); });
}
Optional<size_t> find_first_index(const T& value)
{
for (size_t i = 0; i < m_size; ++i) {
if (value == at(i))
if (Traits<T>::equals(value, at(i)))
return i;
}
return {};