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

Fix HashTable::find() return iterator for items found in non-0 buckets.

This commit is contained in:
Andreas Kling 2018-10-14 22:08:36 +02:00
parent c94044a04a
commit 39444c5916
2 changed files with 31 additions and 15 deletions

View file

@ -40,10 +40,12 @@ public:
{
auto* node = new Node(std::move(value));
if (!m_head) {
ASSERT(!m_tail);
m_head = node;
m_tail = node;
return;
}
ASSERT(m_tail);
m_tail->next = node;
node->prev = m_tail;
m_tail = node;
@ -112,14 +114,20 @@ public:
{
ASSERT(it.m_node);
auto* node = it.m_node;
if (node->prev)
if (node->prev) {
ASSERT(node != m_head);
node->prev->next = node->next;
if (node->next)
node->next->prev = node->prev;
if (m_head == node)
} else {
ASSERT(node == m_head);
m_head = node->next;
if (m_tail == node)
}
if (node->next) {
ASSERT(node != m_tail);
node->next->prev = node->prev;
} else {
ASSERT(node == m_tail);
m_tail = node->prev;
}
delete node;
}