UEC++ From Basics to Advanced | M04-012: Remove Operations

This video covers TArray remove operations. Remove deletes all elements equal to a given value using the operator comparison and returns the count removed. RemoveSingle removes only the first matching element. RemoveAt removes the element at a specified index and asserts if the index is out of bounds. A key distinction is between order-preserving and swap removals. Standard Remove and RemoveAt shift subsequent elements forward to fill gaps, maintaining the original order with O(n) overhead. RemoveSwap and RemoveAllSwap replace the removed element with the last element instead, which is more efficient but does not preserve ordering. RemoveAll uses a predicate lambda to delete all matching elements. Empty clears the entire array and optionally accepts a Slack parameter to retain allocated capacity for reuse. The video also covers performance considerations: fixed-size arrays via SetNum are recommended when the maximum size is known, such as a 30-slot inventory, to avoid repeated expansion and waste.