Which container to choose for optimized performance?

There’s a bunch of containers to choose from: Containers | Unreal Engine Documentation

I need something similar to array except that I’m only adding items to it by insert at zero index to push the items, removing last item if number of items exceeds given limit. Maybe someone knows which container would be more optimized for this (more than TArray :P)?

Probably want something like a circular buffer so you don’t have to actually move the elements, you just change the index you’re addressing with and overwrite the oldest element. TCircularBuffer might be an option.

If you want Reflection support, you can only use TArray, but it should be relatively trivial to implement a circular-buffer lookup function for it and/or wrap it in a USTRUCT() utility. You really want to avoid moving the elements at all if you care about performance.

1 Like

makes sense, thanks