6 #ifndef JLM_UTIL_BIJECTIVE_MAP_HPP
7 #define JLM_UTIL_BIJECTIVE_MAP_HPP
11 #include <unordered_map>
21 template<
typename K,
typename V>
43 explicit ConstIterator(
const typename ForwardMapType::const_iterator & it)
50 return It_.operator*();
56 return It_.operator->();
87 typename ForwardMapType::const_iterator
It_;
105 template<class InputIt>
110 for (
auto it = first; it != last; ++it)
142 [[nodiscard]] std::size_t
174 template<
typename IteratorType>
179 std::is_base_of_v<std::forward_iterator_tag, typename IteratorType::iterator_category>);
203 throw Error(
"Key or value were already present in the BijectiveMap");
233 [[nodiscard]]
const V &
238 throw Error(
"Key not found in BijectiveMap");
247 [[nodiscard]]
const K &
252 throw Error(
"Value not found in BijectiveMap");
261 [[nodiscard]] ConstIterator
272 [[nodiscard]] ConstIterator
288 const size_t removed =
ReverseMap_.erase(it->second);
343 if (
match(it->first, it->second))
367 [&](
const K & key,
const V &)
384 [&](
const K &,
const V & value)
ForwardMapType::const_iterator It_
std::ptrdiff_t difference_type
const ItemType & operator*() const
const ItemType * operator->() const
bool operator!=(const ConstIterator &other) const
ConstIterator & operator++()
std::forward_iterator_tag iterator_category
ConstIterator operator++(int)
ConstIterator(const typename ForwardMapType::const_iterator &it)
bool operator==(const ConstIterator &other) const
~BijectiveMap() noexcept=default
const V & LookupKey(const K &key) const
bool operator!=(const BijectiveMap &other) const noexcept
const K & LookupValue(const V &value) const
size_t RemoveValuesWhere(const F &match)
std::unordered_map< V, K > ReverseMapType
bool RemoveKey(const K &key)
size_t RemoveWhere(const F &match)
BijectiveMap & operator=(const BijectiveMap &other)=default
BijectiveMap & operator=(BijectiveMap &&other)=default
ReverseMapType ReverseMap_
size_t InsertPairs(IteratorType begin, IteratorType end)
ConstIterator begin() const noexcept
std::size_t Size() const noexcept
ConstIterator Erase(ConstIterator it)
std::pair< const K, V > ItemType
ForwardMapType ForwardMap_
bool operator==(const BijectiveMap &other) const noexcept
ConstIterator end() const noexcept
size_t RemoveKeysWhere(const F &match)
bool RemoveValue(const V &value)
void InsertOrThrow(const K &key, const V &value)
std::unordered_map< K, V > ForwardMapType
bool Insert(const K &key, const V &value)
bool HasKey(const K &key) const noexcept
BijectiveMap(std::initializer_list< ItemType > init)
bool HasValue(const V &value) const noexcept
jlm::rvsdg::Output * match(size_t nbits, const std::unordered_map< uint64_t, uint64_t > &mapping, uint64_t default_alternative, size_t nalternatives, jlm::rvsdg::Output *operand)