The best way of using struct, class, and array

In reply to jh_veryveri:

First, I suggest using your tool’s profiling capabilities to make sure you are spending effort in the right places in getting the best performance.

Push/pop of a queue involves allocation/deallocation of an array element to hold a value. Other than that, there is no difference between push/pop versus making an assignment to another variable, you are always coping a value. That includes an input/output arguments of function that copies its value upon entering/exiting the the call.

Then you need to understand that making assignments to class variables is copying the handle referring to a class object, not the object itself. That means a function argument that is a class variable should be an input or output, not a ref. A ref argument makes it a double reference.

Finally, using the builtin find() methods will certainly be more efficient than code you could write yourself to do the exact same thing in most cases. Sometimes using an associated array might be more efficient in looking up key values.