mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03: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
@ -278,6 +278,13 @@ public:
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void unstable_remove(int index)
|
||||||
|
{
|
||||||
|
ASSERT(index < m_size);
|
||||||
|
swap(at(index), at(m_size - 1));
|
||||||
|
take_last();
|
||||||
|
}
|
||||||
|
|
||||||
void remove(int index)
|
void remove(int index)
|
||||||
{
|
{
|
||||||
ASSERT(index < m_size);
|
ASSERT(index < m_size);
|
||||||
|
Loading…
Reference in New Issue
Block a user