mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +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
Notes:
sideshowbarker
2024-07-17 20:16:18 +09:00
Author: https://github.com/drunderscore Commit: https://github.com/SerenityOS/serenity/commit/10b25d2a577 Pull-request: https://github.com/SerenityOS/serenity/pull/12121
1 changed files with 6 additions and 0 deletions
|
@ -205,6 +205,12 @@ public:
|
|||
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
|
||||
{
|
||||
return find(value) != end();
|
||||
|
|
Loading…
Reference in a new issue