Commit 24c32c7d by Evan Brown Committed by Copybara-Service

Use btree iterator subtraction instead of std::distance in erase_range() and count().

PiperOrigin-RevId: 481979737
Change-Id: I69f53665b0463a7d8d80f2a3feedfdd95d32b012
parent 4bc7568c
......@@ -2444,7 +2444,7 @@ auto btree<P>::rebalance_after_delete(iterator iter) -> iterator {
template <typename P>
auto btree<P>::erase_range(iterator begin, iterator end)
-> std::pair<size_type, iterator> {
size_type count = static_cast<size_type>(std::distance(begin, end));
size_type count = static_cast<size_type>(end - begin);
assert(count >= 0);
if (count == 0) {
......
......@@ -107,7 +107,7 @@ class btree_container {
template <typename K = key_type>
size_type count(const key_arg<K> &key) const {
auto equal_range = this->equal_range(key);
return std::distance(equal_range.first, equal_range.second);
return equal_range.second - equal_range.first;
}
template <typename K = key_type>
iterator find(const key_arg<K> &key) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment