mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
AK: Add Vector::unstable_remove(index)
This removes an item at an index without preserving the sort order of the Vector. This enables constant-time removal from unsorted Vectors, as it avoids shifting all of the entries following the removed one.
This commit is contained in:
parent
542098d90d
commit
575664cda3
Notes:
sideshowbarker
2024-07-19 10:02:57 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/575664cda39
1 changed files with 7 additions and 0 deletions
|
@ -278,6 +278,13 @@ public:
|
|||
return value;
|
||||
}
|
||||
|
||||
void unstable_remove(int index)
|
||||
{
|
||||
ASSERT(index < m_size);
|
||||
swap(at(index), at(m_size - 1));
|
||||
take_last();
|
||||
}
|
||||
|
||||
void remove(int index)
|
||||
{
|
||||
ASSERT(index < m_size);
|
||||
|
|
Loading…
Add table
Reference in a new issue