MCPcopy Create free account
hub / github.com/KratosMultiphysics/Kratos / insert

Method insert

kratos/containers/pointer_vector_set.h:571–587  ·  view source on GitHub ↗

* @brief Inserts a pointer. * @details This function inserts a given pointer such that the resulting PointerVectorSet * is kept sorted. If there exists already a pointer with a key same as the key of the value, then * this will return iterator of that existing pointer (The value will not be inserted.) * @param value The pointer to be inserted. * @return An iterator pointin

Source from the content-addressed store, hash-verified

569 * @return An iterator pointing to the inserted element.
570 */
571 iterator insert(const TPointerType& value)
572 {
573 auto itr_pos = std::lower_bound(mData.begin(), mData.end(), KeyOf(*value), CompareKey());
574 if (itr_pos == mData.end()) {
575 // the position to insert is at the end.
576 mData.push_back(value);
577 mSortedPartSize = mData.size();
578 return iterator(mData.end() - 1);
579 } else if (EqualKeyTo(KeyOf(*value))(*itr_pos)) {
580 // already found existing element with the same key, hence returning the existing element.
581 return iterator(itr_pos);
582 } else {
583 // insert the new value before the itr_pos.
584 mSortedPartSize = mData.size() + 1;
585 return mData.insert(itr_pos, value);
586 }
587 }
588
589 /**
590 * @brief Inserts a pointer at the specified position.

Callers 1

PointerVectorSetClass · 0.45

Calls 14

insertFunction · 0.85
distanceFunction · 0.85
CompareKeyClass · 0.70
iteratorClass · 0.70
EqualKeyToClass · 0.70
emptyFunction · 0.50
cendFunction · 0.50
cbeginFunction · 0.50
sortFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected