| 381 | |
| 382 | template <typename Value, typename Key, typename GetKey, typename Hash, typename Equals, typename Allocator> |
| 383 | auto 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 | |
| 411 | template <typename Value, typename Key, typename GetKey, typename Hash, typename Equals, typename Allocator> |
| 412 | auto FlatHashTable<Value, Key, GetKey, Hash, Equals, Allocator>::erase(const_iterator first, const_iterator last) -> iterator { |