MCPcopy Create free account
hub / github.com/catboost/catboost / InsertImpl

Method InsertImpl

library/cpp/cache/cache.h:575–593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

573
574 template<typename TKeyRef, typename TValueRef>
575 bool InsertImpl(TKeyRef&& key, TValueRef&& value) {
576 if (!MultiValue && Index.find(key) != Index.end())
577 return false;
578 TIndexIterator it = Index.emplace(std::forward<TKeyRef>(key), std::forward<TValueRef>(value));
579
580 TItem* insertedItem = const_cast<TItem*>(&*it);
581 auto removedItem = List.Insert(insertedItem);
582 auto insertedWasRemoved = removedItem == insertedItem;
583 if (removedItem) {
584 EraseFromIndex(removedItem);
585 while ((removedItem = List.RemoveIfOverflown())) {
586 insertedWasRemoved = insertedWasRemoved || insertedItem == removedItem;
587 EraseFromIndex(removedItem);
588 }
589 }
590
591 Y_ASSERT(Index.size() == List.GetSize());
592 return !insertedWasRemoved;
593 }
594
595 // a lot of code calls Insert(key, {arguments for TValue constructor})
596 // template version InsertImpl can not process this

Callers

nothing calls this directly

Calls 7

findMethod · 0.45
endMethod · 0.45
emplaceMethod · 0.45
InsertMethod · 0.45
RemoveIfOverflownMethod · 0.45
sizeMethod · 0.45
GetSizeMethod · 0.45

Tested by

no test coverage detected