summaryrefslogtreecommitdiff
path: root/absl/container/btree_map.h
diff options
context:
space:
mode:
Diffstat (limited to 'absl/container/btree_map.h')
-rw-r--r--absl/container/btree_map.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/absl/container/btree_map.h b/absl/container/btree_map.h
index 4eafe062..797b949f 100644
--- a/absl/container/btree_map.h
+++ b/absl/container/btree_map.h
@@ -478,8 +478,11 @@ void swap(btree_map<K, V, C, A> &x, btree_map<K, V, C, A> &y) {
// absl::erase_if(absl::btree_map<>, Pred)
//
// Erases all elements that satisfy the predicate pred from the container.
+// Returns the number of erased elements.
template <typename K, typename V, typename C, typename A, typename Pred>
-void erase_if(btree_map<K, V, C, A> &map, Pred pred) {
+typename btree_map<K, V, C, A>::size_type erase_if(
+ btree_map<K, V, C, A> &map, Pred pred) {
+ const auto initial_size = map.size();
for (auto it = map.begin(); it != map.end();) {
if (pred(*it)) {
it = map.erase(it);
@@ -487,6 +490,7 @@ void erase_if(btree_map<K, V, C, A> &map, Pred pred) {
++it;
}
}
+ return initial_size - map.size();
}
// absl::btree_multimap
@@ -809,8 +813,11 @@ void swap(btree_multimap<K, V, C, A> &x, btree_multimap<K, V, C, A> &y) {
// absl::erase_if(absl::btree_multimap<>, Pred)
//
// Erases all elements that satisfy the predicate pred from the container.
+// Returns the number of erased elements.
template <typename K, typename V, typename C, typename A, typename Pred>
-void erase_if(btree_multimap<K, V, C, A> &map, Pred pred) {
+typename btree_multimap<K, V, C, A>::size_type erase_if(
+ btree_multimap<K, V, C, A> &map, Pred pred) {
+ const auto initial_size = map.size();
for (auto it = map.begin(); it != map.end();) {
if (pred(*it)) {
it = map.erase(it);
@@ -818,6 +825,7 @@ void erase_if(btree_multimap<K, V, C, A> &map, Pred pred) {
++it;
}
}
+ return initial_size - map.size();
}
namespace container_internal {