mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:57:45 +00:00
AK: Support using custom comparison operations for hash compatible keys
This commit is contained in:
parent
4a99170cd2
commit
9b0d90a71d
3 changed files with 8 additions and 8 deletions
|
@ -119,17 +119,16 @@ public:
|
|||
return m_table.find(hash, predicate);
|
||||
}
|
||||
|
||||
// FIXME: Use some sort of Traits to get the comparison operation
|
||||
template<Concepts::HashCompatible<K> Key>
|
||||
requires(IsSame<KeyTraits, Traits<K>>) [[nodiscard]] IteratorType find(Key const& value)
|
||||
requires(IsSame<KeyTraits, Traits<K>>) [[nodiscard]] IteratorType find(Key const& key)
|
||||
{
|
||||
return m_table.find(Traits<Key>::hash(value), [&](auto& entry) { return value == entry.key; });
|
||||
return m_table.find(Traits<Key>::hash(key), [&](auto& entry) { return Traits<K>::equals(key, entry.key); });
|
||||
}
|
||||
|
||||
template<Concepts::HashCompatible<K> Key>
|
||||
requires(IsSame<KeyTraits, Traits<K>>) [[nodiscard]] ConstIteratorType find(Key const& value) const
|
||||
requires(IsSame<KeyTraits, Traits<K>>) [[nodiscard]] ConstIteratorType find(Key const& key) const
|
||||
{
|
||||
return m_table.find(Traits<Key>::hash(value), [&](auto& entry) { return value == entry.key; });
|
||||
return m_table.find(Traits<Key>::hash(key), [&](auto& entry) { return Traits<K>::equals(key, entry.key); });
|
||||
}
|
||||
|
||||
void ensure_capacity(size_t capacity) { m_table.ensure_capacity(capacity); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue