1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 09:34:57 +09:00

AK: Add take_first to HashTable and rename pop to take_last

This naming scheme matches Vector.

This also changes `take_last` to move the value it takes, and delete by
known pointer, avoiding a full lookup and potential copies.
This commit is contained in:
Hediadyoin1 2023-02-21 11:30:52 +01:00 committed by Jelle Raaijmakers
parent 93945062a7
commit fd8c54d720
Notes: sideshowbarker 2024-07-17 17:38:29 +09:00
3 changed files with 45 additions and 8 deletions

View file

@ -405,12 +405,21 @@ public:
return has_removed_anything;
}
T pop()
T take_last()
requires(IsOrdered)
{
VERIFY(!is_empty());
T element = *m_collection_data.tail->slot();
remove(element);
T element = move(*m_collection_data.tail->slot());
delete_bucket(*m_collection_data.tail);
return element;
}
T take_first()
requires(IsOrdered)
{
VERIFY(!is_empty());
T element = move(*m_collection_data.head->slot());
delete_bucket(*m_collection_data.head);
return element;
}