Skip to content

Commit

Permalink
AK: Vector use Traits<T>::equals in find
Browse files Browse the repository at this point in the history
Use Traits<T>::equals for equality checking in search
functions instead of  operator==
  • Loading branch information
tryfinally authored and awesomekling committed Sep 6, 2020
1 parent ad3e6ef commit 125ea6a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions AK/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class Vector {
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;
Expand Down Expand Up @@ -612,18 +612,18 @@ class Vector {

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 {};
Expand Down

0 comments on commit 125ea6a

Please sign in to comment.