in Education by
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? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
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.

Related questions

0 votes
    I am implementing a display algorithm where we can have multiple layers of windows based on their z-order i ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 28, 2022 in Education by JackTerrance
0 votes
    I am implementing a display algorithm where we can have multiple layers of windows based on their z-order i ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    Take the following code snippet: #include std::vector good; //illegal, because std::allocator is ill-formed ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I am working on a very large scale computing library that is using STL heavily. The library is being ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    I am inputting a 200mb file in my application and due to a very strange reason the memory usage of ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    I am inputting a 200mb file in my application and due to a very strange reason the memory usage of ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    I was trying to solve this hiring contest problem (now closed) Lexicographic Rows You are given a matrix of characters. In one ... { //Current is valid if (input[i - 1][j]...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    just wondering what it is. Edit: I know it's not a type of array but just a feature. So what ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    just wondering what it is. Edit: I know it's not a type of array but just a feature. So what ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    I'm trying to put several images together into one big image, and am looking for an algorithm which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I'm trying to put several images together into one big image, and am looking for an algorithm which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I want to write a function that takes an array of letters as an argument and a number of those ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    I want to write a function that takes an array of letters as an argument and a number of those ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
...