mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:48:14 +00:00
AK: Implement HashTable::try_ensure_capacity
, as used in HashMap
This was used in `HashMap::try_ensure_capacity`, but was missing from `HashTable`s implementation. No one had used `HashMap::try_ensure_capacity` before so it went unnoticed!
This commit is contained in:
parent
58b5aede65
commit
10b25d2a57
1 changed files with 6 additions and 0 deletions
|
@ -205,6 +205,12 @@ public:
|
||||||
rehash(capacity * 2);
|
rehash(capacity * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> try_ensure_capacity(size_t capacity)
|
||||||
|
{
|
||||||
|
VERIFY(capacity >= size());
|
||||||
|
return try_rehash(capacity * 2);
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool contains(T const& value) const
|
[[nodiscard]] bool contains(T const& value) const
|
||||||
{
|
{
|
||||||
return find(value) != end();
|
return find(value) != end();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue