mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:47:35 +00:00
AK: Add Vector::remove_all_matching()
This commit is contained in:
parent
9e3e13e410
commit
11d49aedd8
1 changed files with 13 additions and 0 deletions
13
AK/Vector.h
13
AK/Vector.h
|
@ -360,6 +360,18 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Callback>
|
||||||
|
void remove_all_matching(Callback callback)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < size();) {
|
||||||
|
if (callback(at(i))) {
|
||||||
|
remove(i);
|
||||||
|
} else {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void unchecked_append(T&& value)
|
void unchecked_append(T&& value)
|
||||||
{
|
{
|
||||||
ASSERT((size() + 1) <= capacity());
|
ASSERT((size() + 1) <= capacity());
|
||||||
|
@ -535,6 +547,7 @@ public:
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reset_capacity()
|
void reset_capacity()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue