1#ifndef BPMNOS_tuple_map_H
2#define BPMNOS_tuple_map_H
7#include <unordered_map>
26template<
typename Key,
typename Value>
34 component(
const T& value) : value(value) {}
35 uintmax_t operator,(uintmax_t n)
const {
36 n ^= std::hash<T>()(value);
37 n ^= n << (
sizeof(uintmax_t) * 4 - 1);
38 return n ^ std::hash<uintmax_t>()(n);
44 size_t operator()(
const Tuple& tuple)
const {
45 return std::hash<uintmax_t>()( std::apply([](
const auto& ... xs) {
return (component(xs), ..., 0); }, tuple) );
49 std::unordered_map<Key, Value, tuple_hash> map;
52 using iterator =
typename std::unordered_map<Key, Value, tuple_hash>::iterator;
53 using const_iterator =
typename std::unordered_map<Key, Value, tuple_hash>::const_iterator;
54 using size_type =
typename std::unordered_map<Key, Value, tuple_hash>::size_type;
108 std::pair<iterator, bool>
insert(
const std::pair<Key, Value>& value) {
109 return map.insert(value);
117 return map.erase(key);
126 return map.count(key);
130 return map.find(key);
134 return map.find(key);
Wrapper class around std::unordered_map for maps with tuple keys.
size_type count(const Key &key) const
const_iterator cbegin() const noexcept
bool empty() const noexcept
const_iterator cend() const noexcept
typename std::unordered_map< Key, Value, tuple_hash >::size_type size_type
typename std::unordered_map< Key, Value, tuple_hash >::const_iterator const_iterator
typename std::unordered_map< Key, Value, tuple_hash >::iterator iterator
iterator begin() noexcept
Value & at(const Key &key)
Value & operator[](const Key &key)
const Value & at(const Key &key) const
size_type size() const noexcept
const_iterator begin() const noexcept
void swap(tuple_map &other) noexcept
const_iterator end() const noexcept
size_type erase(const Key &key)
std::pair< iterator, bool > insert(const std::pair< Key, Value > &value)
iterator find(const Key &key)
const_iterator find(const Key &key) const
std::variant< bool, int, double, std::string > Value