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

Method emplace_impl

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

Source from the content-addressed store, hash-verified

1482 template <class... ValueArgs, class U = T,
1483 typename std::enable_if<has_mapped_type<U>::value>::type* = nullptr>
1484 std::pair<iterator, bool> emplace_impl(
1485 std::size_t ibucket, typename array_bucket::const_iterator end_of_bucket,
1486 const CharT* key, size_type key_size, ValueArgs&&... value_args) {
1487 if (this->m_values.size() >= max_size()) {
1488 // Try to clear old erased values lingering in m_values. Throw if it
1489 // doesn't change anything.
1490 clear_old_erased_values();
1491 if (this->m_values.size() >= max_size()) {
1492 throw std::length_error(
1493 "Can't insert value, too much values in the map.");
1494 }
1495 }
1496
1497 if (this->m_values.size() == this->m_values.capacity()) {
1498 this->m_values.reserve(
1499 std::size_t(float(this->m_values.size()) *
1500 value_container<T>::VECTOR_GROWTH_RATE));
1501 }
1502
1503 this->m_values.emplace_back(std::forward<ValueArgs>(value_args)...);
1504
1505 try {
1506 auto it = m_buckets[ibucket].append(
1507 end_of_bucket, key, key_size, IndexSizeT(this->m_values.size() - 1));
1508 m_nb_elements++;
1509
1510 return std::make_pair(
1511 iterator(m_buckets_data.begin() + ibucket, it, this), true);
1512 } catch (...) {
1513 // Rollback
1514 this->m_values.pop_back();
1515 throw;
1516 }
1517 }
1518
1519 template <class U = T, typename std::enable_if<
1520 !has_mapped_type<U>::value>::type* = nullptr>

Callers

nothing calls this directly

Calls 10

size_tFunction · 0.85
max_sizeFunction · 0.50
iteratorClass · 0.50
sizeMethod · 0.45
capacityMethod · 0.45
reserveMethod · 0.45
emplace_backMethod · 0.45
appendMethod · 0.45
beginMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected