I am implementing a display algorithm where we can have multiple layers of windows based on their z-order i.e. I start with the last z-value and merge the images until we have the image with the z-value as 0 at the top.
To maintain the z-values which data structure do you recommend?
For eg: If the z-order is 2 3 4 5 1 6 7 8 9 10 (index of the Application) and if the user has clicked on the Application 5’s window then we need to move 5 to the front and the remaining order should be the same i.e. 5 2 3 4 1 6 7 8 9 10.
If I use vector then rearranging the elements (or copying the values) every time doesn’t seem to be efficient.
If I use deque then push_front has some obvious advantage but again removing the Application from its previous position is the problem.
If I use list then every time we need to search for the element and remove it.
Any thoughts on which data structure is the most efficient for my purpose?
Given that the number of windows is probably going to be minimal, I would probably go with a vector of (smart) pointers, and reorder the vector components. While the complexity is greater than with other alternatives, the actual performance will not be bad, as the constants might dominate the complexity.