| 14 | class HashMap { |
| 15 | public: |
| 16 | class Entry { |
| 17 | public: |
| 18 | Entry(const K &k, const V &v) : key(k), value(v) {} |
| 19 | |
| 20 | Entry(const Entry &) = delete; |
| 21 | |
| 22 | Entry &operator=(const Entry &) = delete; |
| 23 | |
| 24 | [[nodiscard]] K getKey() const { |
| 25 | return key; |
| 26 | } |
| 27 | |
| 28 | [[nodiscard]] V *getValue() const { |
| 29 | return &value; |
| 30 | } |
| 31 | |
| 32 | template<typename... Args> |
| 33 | void setValue(Args &&...args) const { |
| 34 | value = V(std::forward<Args>(args)...); |
| 35 | } |
| 36 | |
| 37 | void setValue(V &v) const { |
| 38 | value = v; |
| 39 | } |
| 40 | |
| 41 | private: |
| 42 | const K key; |
| 43 | mutable V value; |
| 44 | }; |
| 45 | |
| 46 | private: |
| 47 | std::unordered_map<K, std::shared_ptr<Entry>, Hash, Pred> backend; |
nothing calls this directly
no outgoing calls
no test coverage detected