Description
Removes all elements for which the predicate returns true, preserving order of remaining elements. Returns the number removed.
Signature
SizeType RemoveAll(const PREDICATE_CLASS& Predicate) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Predicate | PREDICATE_CLASS | A callable that returns true for elements that should be removed. | — |
Return Type
int32 Caveats & Gotchas
- • Uses a stable partition internally — remaining elements preserve their relative order.
- • The predicate must not modify the array. Capture by value or use a const reference.
- • For a swap-based (non-order-preserving) variant that is faster on large arrays, use RemoveAllSwap().
Example
Remove null pointers and expired actors C++
// Remove all null or invalid actors
TrackedActors.RemoveAll([](AActor* Actor)
{
return !IsValid(Actor);
});
// Remove all enemies with zero health
Enemies.RemoveAll([](const AEnemy* Enemy)
{
return Enemy->Health <= 0.0f;
}); Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?