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:
parent
c94044a04a
commit
39444c5916
2 changed files with 31 additions and 15 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue