mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:47:45 +00:00
AK: Make all DoublyLinkedList search methods use Traits<T>::equals (#3404)
This commit is contained in:
parent
02b3cb8123
commit
fad0c8e712
1 changed files with 17 additions and 14 deletions
|
@ -133,11 +133,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_node(value) != nullptr;
|
||||||
if (node->value == value)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using Iterator = DoublyLinkedListIterator<DoublyLinkedList, T>;
|
using Iterator = DoublyLinkedListIterator<DoublyLinkedList, T>;
|
||||||
|
@ -152,19 +148,17 @@ public:
|
||||||
|
|
||||||
ConstIterator find(const T& value) const
|
ConstIterator find(const T& value) const
|
||||||
{
|
{
|
||||||
for (auto* node = m_head; node; node = node->next) {
|
Node* node = find_node(value);
|
||||||
if (Traits<T>::equals(node->value, value))
|
if (node)
|
||||||
return ConstIterator(node);
|
return ConstIterator(node);
|
||||||
}
|
|
||||||
return end();
|
return end();
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator find(const T& value)
|
Iterator find(const T& value)
|
||||||
{
|
{
|
||||||
for (auto* node = m_head; node; node = node->next) {
|
Node* node = find_node(value);
|
||||||
if (Traits<T>::equals(node->value, value))
|
if (node)
|
||||||
return Iterator(node);
|
return Iterator(node);
|
||||||
}
|
|
||||||
return end();
|
return end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,6 +214,15 @@ private:
|
||||||
m_head = node;
|
m_head = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node* find_node(const T& value) const
|
||||||
|
{
|
||||||
|
for (auto* node = m_head; node; node = node->next) {
|
||||||
|
if (Traits<T>::equals(node->value, value))
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
Node* head() { return m_head; }
|
Node* head() { return m_head; }
|
||||||
const Node* head() const { return m_head; }
|
const Node* head() const { return m_head; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue