AK: Add values() method in HashTable

Add HashTable::values() method that returns all values.
This commit is contained in:
Aliaksandr Kalenik 2023-04-28 15:02:38 +03:00 committed by Andreas Kling
commit 4c6564e3c1
Notes: sideshowbarker 2024-07-17 06:51:10 +09:00
2 changed files with 25 additions and 0 deletions

View file

@ -10,6 +10,7 @@
#include <AK/DeprecatedString.h>
#include <AK/HashTable.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/Vector.h>
TEST_CASE(construct)
{
@ -434,3 +435,18 @@ TEST_CASE(ordered_infinite_loop_clang_regression)
}
}
}
TEST_CASE(values)
{
OrderedHashTable<int> table;
table.set(10);
table.set(30);
table.set(20);
Vector<int> values = table.values();
EXPECT_EQ(values.size(), table.size());
EXPECT_EQ(values[0], 10);
EXPECT_EQ(values[1], 30);
EXPECT_EQ(values[2], 20);
}