c++ - how to compare two elements in priority_queue -
i defined priority_queue<pair<double, int>>. smaller double value has higher priority. if there several same double values in queue, pop 1 randomly. example: (<0.1, 1>, <0.1,2>, <0.1, 0>,<0.1,5>), how pop 1 of them randomly? not sure if idea reasonable. because location of element has been determined ,when pushed queue.
you store tuples double, int, int, last term unique random number comparator use resolve comparisons of equivalent elements.
Comments
Post a Comment