diff options
Diffstat (limited to 'src/hash_map.hh')
| -rw-r--r-- | src/hash_map.hh | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/hash_map.hh b/src/hash_map.hh index f5bc9412..2f2f6042 100644 --- a/src/hash_map.hh +++ b/src/hash_map.hh @@ -194,9 +194,9 @@ struct HashMap insert(*begin++); } - constexpr EffectiveValue& insert(Item item) + constexpr EffectiveValue& insert(Item item, size_t hash) { - const auto hash = hash_value(item_key(item)); + kak_assert(hash == hash_value(item_key(item))); if constexpr (not multi_key) { if (auto index = find_index(item_key(item), hash); index >= 0) @@ -212,6 +212,11 @@ struct HashMap return item_value(m_items.back()); } + constexpr EffectiveValue& insert(Item item) + { + return insert(std::move(item), hash_value(item_key(item))); + } + template<typename KeyType> requires IsHashCompatible<Key, KeyType> constexpr int find_index(const KeyType& key, size_t hash) const { @@ -313,6 +318,7 @@ struct HashMap constexpr const_iterator begin() const { return m_items.begin(); } constexpr const_iterator end() const { return m_items.end(); } + Item& item(size_t index) { return m_items[index]; } const Item& item(size_t index) const { return m_items[index]; } template<typename KeyType> requires IsHashCompatible<Key, KeyType> |
