1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +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:
Idan Horowitz 2021-06-15 23:46:54 +03:00 committed by Linus Groh
parent 08ff148bc3
commit 8c7fe8d6c8
4 changed files with 60 additions and 28 deletions

View file

@ -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);
}
}