TArray Stack O(N)?

Hi,

I was looking over the TArray header file as I intended to use it as a Stack using its’ Pop and Push functionality. However looking over the Pop function in the TArray, it uses the standard TArray RemoveAt function. I may be missing something, but removal of elements is said to be O(N) in the API.

Is this implementation actually constant time, or is there another Stack implementation available in UE4 which is?

Thanks for any and all help :slight_smile:

Thanks for the response!

Yeah I think you are right, as it is a pop operation on the final element, so no memory movement is required. Sorry for the confusion

Whats the Problem? It removes a known index O(1) it does not do any search trough the array. You confuse it with the RemoveElement I guess where the Element has to be found first O(N).