MCPcopy Create free account
hub / github.com/apache/arrow / insert

Method insert

cpp/src/arrow/util/small_vector.h:393–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391
392 template <typename InputIt>
393 iterator insert(const_iterator insert_at, InputIt first, InputIt last) {
394 const size_t n = storage_.size_;
395 const size_t it_size = static_cast<size_t>(last - first); // XXX might be O(n)?
396 const size_t pos = static_cast<size_t>(insert_at - const_data_ptr());
397 storage_.bump_size(it_size);
398 auto* p = storage_.storage_ptr();
399 if (it_size == 0) {
400 return p[pos].get();
401 }
402 const size_t end_pos = pos + it_size;
403
404 // Move [pos; n) to [end_pos; end_pos + n - pos)
405 size_t i = n;
406 size_t j = end_pos + n - pos;
407 while (j > std::max(n, end_pos)) {
408 p[--j].move_construct(&p[--i]);
409 }
410 while (j > end_pos) {
411 p[--j].move_assign(&p[--i]);
412 }
413 assert(j == end_pos);
414 // Copy [first; last) to [pos; end_pos)
415 j = pos;
416 while (j < std::min(n, end_pos)) {
417 p[j++].assign(*first++);
418 }
419 while (j < end_pos) {
420 p[j++].construct(*first++);
421 }
422 assert(first == last);
423 return p[pos].get();
424 }
425
426 void resize(size_t n) {
427 const size_t old_size = storage_.size_;

Callers 15

FlattenMethod · 0.45
operator()Method · 0.45
ExtendFunction · 0.45
CheckTypeIdReprsFunction · 0.45
TEST_FFunction · 0.45
MaterializedFieldsMethod · 0.45
GenerateSubtreesMethod · 0.45
GetNextFilenameMethod · 0.45
AsFragmentVectorFunction · 0.45

Calls 7

move_assignMethod · 0.80
assignMethod · 0.80
bump_sizeMethod · 0.45
storage_ptrMethod · 0.45
getMethod · 0.45
move_constructMethod · 0.45
constructMethod · 0.45