sparse_set: better, faster range remove

This commit is contained in:
Michele Caini
2023-01-10 08:43:02 +01:00
parent ecd3b8d933
commit 254da2c3c6

View File

@@ -789,8 +789,25 @@ public:
size_type remove(It first, It last) {
size_type count{};
for(; first != last; ++first) {
count += remove(*first);
if constexpr(std::is_same_v<It, basic_iterator>) {
while(first != last) {
while(first != last && !contains(*first)) {
++first;
}
const auto it = first;
while(first != last && contains(*first)) {
++first;
}
count += std::distance(it, first);
erase(it, first);
}
} else {
for(; first != last; ++first) {
count += remove(*first);
}
}
return count;