mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:57:35 +00:00
AK+Tests: Add Vector::find_first_index_if()
This commit is contained in:
parent
1352f8820b
commit
89e55c5297
2 changed files with 17 additions and 0 deletions
|
@ -796,6 +796,15 @@ public:
|
|||
return {};
|
||||
}
|
||||
|
||||
template<typename TUnaryPredicate>
|
||||
Optional<size_t> find_first_index_if(TUnaryPredicate&& finder) const
|
||||
{
|
||||
auto maybe_result = AK::find_if(begin(), end(), finder);
|
||||
if (maybe_result == end())
|
||||
return {};
|
||||
return maybe_result.index();
|
||||
}
|
||||
|
||||
void reverse()
|
||||
{
|
||||
for (size_t i = 0; i < size() / 2; ++i)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue