MCPcopy Create free account
hub / github.com/ablab/spades / append

Method append

ext/include/tsl/array-hash/array_hash.h:459–500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457 */
458 template <class... ValueArgs>
459 const_iterator append(const_iterator end_of_bucket, const CharT* key,
460 size_type key_size, ValueArgs&&... value) {
461 const key_size_type key_sz = as_key_size_type(key_size);
462
463 if (end_of_bucket == cend()) {
464 tsl_ah_assert(m_buffer == nullptr);
465
466 const size_type buffer_size = entry_required_bytes(key_sz) +
467 sizeof_in_buff<decltype(END_OF_BUCKET)>();
468
469 m_buffer = static_cast<CharT*>(std::malloc(buffer_size));
470 if (m_buffer == nullptr) {
471 throw std::bad_alloc();
472 }
473
474 append_impl(key, key_sz, m_buffer, std::forward<ValueArgs>(value)...);
475
476 return const_iterator(m_buffer);
477 } else {
478 tsl_ah_assert(is_end_of_bucket(end_of_bucket.m_position));
479
480 const size_type current_size =
481 ((end_of_bucket.m_position +
482 size_as_char_t<decltype(END_OF_BUCKET)>()) -
483 m_buffer) *
484 sizeof(CharT);
485 const size_type new_size = current_size + entry_required_bytes(key_sz);
486
487 CharT* new_buffer = static_cast<CharT*>(std::realloc(m_buffer, new_size));
488 if (new_buffer == nullptr) {
489 throw std::bad_alloc();
490 }
491 m_buffer = new_buffer;
492
493 CharT* buffer_append_pos = m_buffer + current_size / sizeof(CharT) -
494 size_as_char_t<decltype(END_OF_BUCKET)>();
495 append_impl(key, key_sz, buffer_append_pos,
496 std::forward<ValueArgs>(value)...);
497
498 return const_iterator(buffer_append_pos);
499 }
500 }
501
502 const_iterator erase(const_iterator position) noexcept {
503 tsl_ah_assert(position.m_position != nullptr &&

Callers 3

keyMethod · 0.45
emplace_implMethod · 0.45

Calls 2

cendFunction · 0.50
const_iteratorClass · 0.50

Tested by

no test coverage detected