I have a operation that continuously generates random solutions (std::vector<float>
). I evaluate the solutions against a mathematical function to see their usefulness (float). I would like to store the top 10 solutions all the time. What would be the most efficient way to do this in C++?
I need to store both the solutions(std::vector) and their usefulness (float). I am performing several hundred thousands of evaluations and hence I am in need of an efficient solution.
Edit: I am aware of sorting methods. I am looking for methods other than sorting and storing the values. Looking for better data structures if any.