| 194 | /// @return A pointer to the value or `nullptr` if the map is full |
| 195 | template <typename ComparableToKey> |
| 196 | [[nodiscard]] Value* getOrCreate(const ComparableToKey& key) |
| 197 | { |
| 198 | for (auto& item : items) |
| 199 | { |
| 200 | if (item.key == key) |
| 201 | { |
| 202 | return &item.value; |
| 203 | } |
| 204 | } |
| 205 | if (items.push_back({key, Value()})) |
| 206 | { |
| 207 | return &items.back().value; |
| 208 | } |
| 209 | return nullptr; |
| 210 | } |
| 211 | }; |
| 212 | //! @} |