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:
parent
93945062a7
commit
fd8c54d720
Notes:
sideshowbarker
2024-07-17 17:38:29 +09:00
Author: https://github.com/Hendiadyoin1
Commit: fd8c54d720
Pull-request: https://github.com/SerenityOS/serenity/pull/17560
Reviewed-by: https://github.com/gmta ✅
3 changed files with 45 additions and 8 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue