mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:27:43 +00:00
Add HashTable::remove() and fix a bug where ConstIterator would skip the first.
This commit is contained in:
parent
f794190de0
commit
c2ef54c044
2 changed files with 48 additions and 3 deletions
28
AK/test.cpp
28
AK/test.cpp
|
@ -155,5 +155,33 @@ int main(int, char**)
|
|||
printInts(v);
|
||||
}
|
||||
|
||||
{
|
||||
auto printInts = [] (const HashTable<int>& h) {
|
||||
printf("HashTable {\n size: %u\n capacity: %u\n elements: ", h.size(), h.capacity());
|
||||
for (auto i : h)
|
||||
printf("%d ", i);
|
||||
printf("\n}\n");
|
||||
};
|
||||
|
||||
HashTable<int> h;
|
||||
|
||||
h.set(10);
|
||||
h.set(20);
|
||||
h.set(30);
|
||||
h.set(40);
|
||||
h.set(50);
|
||||
|
||||
h.dump();
|
||||
|
||||
printInts(h);
|
||||
|
||||
h.remove(30);
|
||||
printInts(h);
|
||||
|
||||
h.set(30);
|
||||
h.remove(30);
|
||||
printInts(h);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue