mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:17:35 +00:00
AK: SinglyLinkedList use Traits<T>::equals in find
Use Traits<T>::equals for equality checking in search functions instead of operator==
This commit is contained in:
parent
f1a6884a51
commit
ad3e6ef344
1 changed files with 6 additions and 9 deletions
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include <AK/Assertions.h>
|
#include <AK/Assertions.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
|
#include <AK/Traits.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
@ -152,11 +153,7 @@ public:
|
||||||
|
|
||||||
bool contains_slow(const T& value) const
|
bool contains_slow(const T& value) const
|
||||||
{
|
{
|
||||||
for (auto* node = m_head; node; node = node->next) {
|
return find(value) != end();
|
||||||
if (node->value == value)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using Iterator = SinglyLinkedListIterator<SinglyLinkedList, T>;
|
using Iterator = SinglyLinkedListIterator<SinglyLinkedList, T>;
|
||||||
|
@ -195,12 +192,12 @@ public:
|
||||||
|
|
||||||
ConstIterator find(const T& value) const
|
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)
|
Iterator find(const T& value)
|
||||||
{
|
{
|
||||||
return find([&](auto& other) { return value == other; });
|
return find([&](auto& other) { return Traits<T>::equals(value, other); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove(Iterator iterator)
|
void remove(Iterator iterator)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue