Skip to content

Commit

Permalink
make BijectiveMap behave nicer by removing const
Browse files Browse the repository at this point in the history
  • Loading branch information
haved committed Feb 3, 2025
1 parent 8a11b3f commit 838a669
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions jlm/util/BijectiveMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ namespace jlm::util
template<typename K, typename V>
class BijectiveMap
{
using ForwardMapType = std::unordered_map<K, const V>;
using ReverseMapType = std::unordered_map<V, const K>;
using ForwardMapType = std::unordered_map<K, V>;
using ReverseMapType = std::unordered_map<V, K>;

public:
using ItemType = std::pair<const K, const V>;
using ItemType = std::pair<const K, V>;

class ConstIterator final
{
Expand Down Expand Up @@ -177,7 +177,6 @@ class BijectiveMap
{
static_assert(
std::is_base_of_v<std::forward_iterator_tag, typename IteratorType::iterator_category>);
static_assert(std::is_base_of_v<ItemType, typename IteratorType::value_type>);

size_t inserted = 0;
while (begin != end)
Expand Down Expand Up @@ -212,7 +211,7 @@ class BijectiveMap
[[nodiscard]] bool
HasKey(const K & key) const noexcept
{
return ForwardMap_.find(key) != ForwardMap_.end();
return ForwardMap_.count(key);
}

/**
Expand All @@ -223,7 +222,7 @@ class BijectiveMap
[[nodiscard]] bool
HasValue(const V & value) const noexcept
{
return ReverseMap_.find(value) != ReverseMap_.end();
return ReverseMap_.count(value);
}

/**
Expand Down

0 comments on commit 838a669

Please sign in to comment.