MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / insertOrAssignImpl

Method insertOrAssignImpl

libCacheSim/dataStructure/robin_hood.h:2275–2302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2273
2274 template <typename OtherKey, typename Mapped>
2275 std::pair<iterator, bool> insertOrAssignImpl(OtherKey&& key, Mapped&& obj) {
2276 ROBIN_HOOD_TRACE(this)
2277 auto idxAndState = insertKeyPrepareEmptySpot(key);
2278 switch (idxAndState.second) {
2279 case InsertionState::key_found:
2280 mKeyVals[idxAndState.first].getSecond() = std::forward<Mapped>(obj);
2281 break;
2282
2283 case InsertionState::new_node:
2284 ::new (static_cast<void*>(&mKeyVals[idxAndState.first])) Node(
2285 *this, std::piecewise_construct, std::forward_as_tuple(std::forward<OtherKey>(key)),
2286 std::forward_as_tuple(std::forward<Mapped>(obj)));
2287 break;
2288
2289 case InsertionState::overwrite_node:
2290 mKeyVals[idxAndState.first] = Node(*this, std::piecewise_construct,
2291 std::forward_as_tuple(std::forward<OtherKey>(key)),
2292 std::forward_as_tuple(std::forward<Mapped>(obj)));
2293 break;
2294
2295 case InsertionState::overflow_error:
2296 throwOverflowError();
2297 break;
2298 }
2299
2300 return std::make_pair(iterator(mKeyVals + idxAndState.first, mInfo + idxAndState.first),
2301 InsertionState::key_found != idxAndState.second);
2302 }
2303
2304 void initData(size_t max_elements) {
2305 mNumElements = 0;

Callers

nothing calls this directly

Calls 2

iteratorClass · 0.70
getSecondMethod · 0.45

Tested by

no test coverage detected