MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / getOrCreate

Method getOrCreate

Libraries/Containers/VectorMap.h:196–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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//! @}

Callers

nothing calls this directly

Calls 1

push_backMethod · 0.45

Tested by

no test coverage detected