mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
AK: Add HashTable::remove_all_matching(predicate)
This removes all matching entries from a table in a single pass.
This commit is contained in:
parent
365bd8a0c3
commit
54cf42fac1
2 changed files with 37 additions and 1 deletions
|
@ -84,6 +84,26 @@ TEST_CASE(table_remove)
|
|||
EXPECT(strings.find("Two") != strings.end());
|
||||
}
|
||||
|
||||
TEST_CASE(table_remove_all_matching)
|
||||
{
|
||||
HashTable<int> ints;
|
||||
|
||||
ints.set(1);
|
||||
ints.set(2);
|
||||
ints.set(3);
|
||||
ints.set(4);
|
||||
|
||||
EXPECT_EQ(ints.size(), 4u);
|
||||
|
||||
ints.remove_all_matching([&](int value) { return value > 2; });
|
||||
|
||||
EXPECT_EQ(ints.size(), 2u);
|
||||
|
||||
ints.remove_all_matching([&](int) { return true; });
|
||||
|
||||
EXPECT(ints.is_empty());
|
||||
}
|
||||
|
||||
TEST_CASE(case_insensitive)
|
||||
{
|
||||
HashTable<String, CaseInsensitiveStringTraits> casetable;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue