mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:18:12 +00:00
AK: Sprinkle [[nodiscard]] on HashMap and HashTable
This commit is contained in:
parent
3d0c5814d2
commit
f65b039c44
2 changed files with 23 additions and 23 deletions
20
AK/HashMap.h
20
AK/HashMap.h
|
@ -71,26 +71,26 @@ public:
|
|||
using IteratorType = typename HashTableType::Iterator;
|
||||
using ConstIteratorType = typename HashTableType::ConstIterator;
|
||||
|
||||
IteratorType begin() { return m_table.begin(); }
|
||||
IteratorType end() { return m_table.end(); }
|
||||
IteratorType find(const K& key)
|
||||
[[nodiscard]] IteratorType begin() { return m_table.begin(); }
|
||||
[[nodiscard]] IteratorType end() { return m_table.end(); }
|
||||
[[nodiscard]] IteratorType find(const K& key)
|
||||
{
|
||||
return m_table.find(KeyTraits::hash(key), [&](auto& entry) { return KeyTraits::equals(key, entry.key); });
|
||||
}
|
||||
template<typename TUnaryPredicate>
|
||||
IteratorType find(unsigned hash, TUnaryPredicate predicate)
|
||||
[[nodiscard]] IteratorType find(unsigned hash, TUnaryPredicate predicate)
|
||||
{
|
||||
return m_table.find(hash, predicate);
|
||||
}
|
||||
|
||||
ConstIteratorType begin() const { return m_table.begin(); }
|
||||
ConstIteratorType end() const { return m_table.end(); }
|
||||
ConstIteratorType find(const K& key) const
|
||||
[[nodiscard]] ConstIteratorType begin() const { return m_table.begin(); }
|
||||
[[nodiscard]] ConstIteratorType end() const { return m_table.end(); }
|
||||
[[nodiscard]] ConstIteratorType find(const K& key) const
|
||||
{
|
||||
return m_table.find(KeyTraits::hash(key), [&](auto& entry) { return KeyTraits::equals(key, entry.key); });
|
||||
}
|
||||
template<typename TUnaryPredicate>
|
||||
ConstIteratorType find(unsigned hash, TUnaryPredicate predicate) const
|
||||
[[nodiscard]] ConstIteratorType find(unsigned hash, TUnaryPredicate predicate) const
|
||||
{
|
||||
return m_table.find(hash, predicate);
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
return (*it).value;
|
||||
}
|
||||
|
||||
bool contains(const K& key) const
|
||||
[[nodiscard]] bool contains(const K& key) const
|
||||
{
|
||||
return find(key) != end();
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public:
|
|||
return find(key)->value;
|
||||
}
|
||||
|
||||
Vector<K> keys() const
|
||||
[[nodiscard]] Vector<K> keys() const
|
||||
{
|
||||
Vector<K> list;
|
||||
list.ensure_capacity(size());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue