MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / insert

Method insert

dnn/include/megdnn/thin/small_vector.h:443–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441 }
442
443 iterator insert(iterator it, T&& elm) {
444 if (it == this->end()) { // Important special case for empty vector.
445 this->push_back(std::move(elm));
446 return this->end() - 1;
447 }
448
449 if (this->m_end_ptr >= this->m_capacity_ptr) {
450 size_t elm_idx = it - this->begin();
451 this->grow();
452 it = this->begin() + elm_idx;
453 }
454
455 new (static_cast<void*>(this->end())) T(std::move(this->back()));
456 // Push everything else over.
457 std::move_backward(it, this->end() - 1, this->end());
458 this->set_end(this->end() + 1);
459
460 // If we just moved the element we're inserting, be sure to update
461 // the reference.
462 T* elm_ptr = &elm;
463 if (it <= elm_ptr && elm_ptr < this->m_end_ptr)
464 ++elm_ptr;
465
466 *it = std::move(*elm_ptr);
467 return it;
468 }
469
470 iterator insert(iterator it, const T& _elm) {
471 if (it == this->end()) { // Important special case for empty vector.

Callers 15

TEST_FFunction · 0.45
TEST_FFunction · 0.45
genMethod · 0.45
~ConstructableMethod · 0.45
TYPED_TESTFunction · 0.45
TESTFunction · 0.45
get_quantized_argsFunction · 0.45
flatten_search_spaceMethod · 0.45
TaskExecutorMethod · 0.45
CheckerClass · 0.45

Calls 10

backMethod · 0.80
set_endMethod · 0.80
copyFunction · 0.50
endMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
growMethod · 0.45
sizeMethod · 0.45
uninitialized_moveMethod · 0.45
uninitialized_copyMethod · 0.45

Tested by 11

TEST_FFunction · 0.36
TEST_FFunction · 0.36
genMethod · 0.36
~ConstructableMethod · 0.36
TYPED_TESTFunction · 0.36
TESTFunction · 0.36
get_quantized_argsFunction · 0.36
flatten_search_spaceMethod · 0.36
TaskExecutorMethod · 0.36