diff --git a/rpcs3/Emu/RSX/Common/simple_array.hpp b/rpcs3/Emu/RSX/Common/simple_array.hpp index 29f43db900..6650fb06d3 100644 --- a/rpcs3/Emu/RSX/Common/simple_array.hpp +++ b/rpcs3/Emu/RSX/Common/simple_array.hpp @@ -282,5 +282,35 @@ namespace rsx { return _data ? _data + _size : nullptr; } + + bool any(std::predicate auto predicate) const + { + for (auto it = begin(); it != end(); ++it) + { + if (std::invoke(predicate, *it)) + { + return true; + } + } + return false; + } + + void filter(std::predicate 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); + } + } + } }; }