1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 12:17:35 +00:00

AK: Defer to Traits<T> for equality comparison in container templates.

This is prep work for supporting HashMap with NonnullRefPtr<T> as values.
It's currently not possible because many HashTable functions require being
able to default-construct the value type.
This commit is contained in:
Andreas Kling 2019-06-29 19:14:03 +02:00
parent 9a7dc06567
commit d5bb98acbc
14 changed files with 61 additions and 31 deletions

View file

@ -1,7 +1,8 @@
#pragma once
#include "StdLibExtras.h"
#include <AK/Assertions.h>
#include <AK/StdLibExtras.h>
#include <AK/Traits.h>
namespace AK {
@ -116,7 +117,7 @@ public:
ConstIterator find(const T& value) const
{
for (auto* node = m_head; node; node = node->next) {
if (node->value == value)
if (Traits<T>::equals(node->value, value))
return ConstIterator(node);
}
return end();
@ -125,7 +126,7 @@ public:
Iterator find(const T& value)
{
for (auto* node = m_head; node; node = node->next) {
if (node->value == value)
if (Traits<T>::equals(node->value, value))
return Iterator(node);
}
return end();