mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
AK: Add support for removing SinglyLinkedList nodes during iteration
This commit also fixes the now-broken usage of SinglyLinkedList::remove in the Piano application.
This commit is contained in:
parent
08ff148bc3
commit
8c7fe8d6c8
Notes:
sideshowbarker
2024-07-18 12:12:46 +09:00
Author: https://github.com/IdanHo
Commit: 8c7fe8d6c8
Pull-request: https://github.com/SerenityOS/serenity/pull/8075
Reviewed-by: https://github.com/linusg
4 changed files with 60 additions and 28 deletions
|
@ -59,3 +59,14 @@ TEST_CASE(should_find_const_with_predicate)
|
|||
|
||||
EXPECT_EQ(sut.end(), sut.find_if([](const auto v) { return v == 42; }));
|
||||
}
|
||||
|
||||
TEST_CASE(removal_during_iteration)
|
||||
{
|
||||
auto list = make_list();
|
||||
auto size = list.size_slow();
|
||||
|
||||
for (auto it = list.begin(); it != list.end(); ++it, --size) {
|
||||
VERIFY(list.size_slow() == size);
|
||||
it.remove(list);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue