summaryrefslogtreecommitdiff
path: root/AK/Vector.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-01-05 17:00:17 +0100
committerAndreas Kling <kling@serenityos.org>2022-01-05 18:57:14 +0100
commit558fb0a04ae33609a62d4d29de9d89ce0cdd7b13 (patch)
treecb27032fd5cf598ad27107c9261d564f31e1169e /AK/Vector.h
parent5279a04c787d0a9521f96ddecc9690997bf2f16d (diff)
downloadserenity-558fb0a04ae33609a62d4d29de9d89ce0cdd7b13.zip
AK: Make Vector::remove_all_matching() return removal success
This matches the behavior of other remove_*_matching() functions.
Diffstat (limited to 'AK/Vector.h')
-rw-r--r--AK/Vector.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/AK/Vector.h b/AK/Vector.h
index d04b34f83d..4dcedf933a 100644
--- a/AK/Vector.h
+++ b/AK/Vector.h
@@ -405,15 +405,18 @@ public:
}
template<typename TUnaryPredicate>
- void remove_all_matching(TUnaryPredicate predicate)
+ bool remove_all_matching(TUnaryPredicate predicate)
{
+ bool something_was_removed = false;
for (size_t i = 0; i < size();) {
if (predicate(at(i))) {
remove(i);
+ something_was_removed = true;
} else {
++i;
}
}
+ return something_was_removed;
}
ALWAYS_INLINE T take_last()