mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 04:02:42 +01:00
rsx: Add some handy util functions to simple_array
This commit is contained in:
parent
0dd9c386ee
commit
f66eaf8f44
@ -282,5 +282,35 @@ namespace rsx
|
||||
{
|
||||
return _data ? _data + _size : nullptr;
|
||||
}
|
||||
|
||||
bool any(std::predicate<const Ty&> auto predicate) const
|
||||
{
|
||||
for (auto it = begin(); it != end(); ++it)
|
||||
{
|
||||
if (std::invoke(predicate, *it))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void filter(std::predicate<const Ty&> auto predicate)
|
||||
{
|
||||
if (!_size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto ptr = _data, last = _data + _size - 1; ptr < last; ptr++)
|
||||
{
|
||||
if (!predicate(*ptr))
|
||||
{
|
||||
// Move item to the end of the list and shrink by 1
|
||||
std::memcpy(ptr, last, sizeof(Ty));
|
||||
last = _data + (--_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user