MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / erase

Method erase

source/core/StarFlatHashTable.hpp:383–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

381
382template <typename Value, typename Key, typename GetKey, typename Hash, typename Equals, typename Allocator>
383auto FlatHashTable<Value, Key, GetKey, Hash, Equals, Allocator>::erase(const_iterator pos) -> iterator {
384 size_t bucketIndex = pos.current - m_buckets.data();
385 size_t currentBucketIndex = bucketIndex;
386 auto currentBucket = &m_buckets[currentBucketIndex];
387
388 while (true) {
389 size_t nextBucketIndex = hashBucket(currentBucketIndex + 1);
390 auto nextBucket = &m_buckets[nextBucketIndex];
391 if (auto nextPtr = nextBucket->valuePtr()) {
392 if (bucketError(nextBucketIndex, nextBucket->hash) > 0) {
393 currentBucket->hash = nextBucket->hash;
394 *currentBucket->valuePtr() = std::move(*nextPtr);
395 currentBucketIndex = nextBucketIndex;
396 currentBucket = nextBucket;
397 } else {
398 break;
399 }
400 } else {
401 break;
402 }
403 }
404
405 m_buckets[currentBucketIndex].setEmpty();
406 --m_filledCount;
407
408 return iterator{scan(m_buckets.data() + bucketIndex)};
409}
410
411template <typename Value, typename Key, typename GetKey, typename Hash, typename Equals, typename Allocator>
412auto FlatHashTable<Value, Key, GetKey, Hash, Equals, Allocator>::erase(const_iterator first, const_iterator last) -> iterator {

Callers

nothing calls this directly

Calls 3

valuePtrMethod · 0.80
setEmptyMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected