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:
James Puleo 2022-01-24 19:31:20 -05:00 committed by Andreas Kling
parent 58b5aede65
commit 10b25d2a57

View file

@ -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();