Answers for "how do comparotor work in c++ priority queue"

C++
0

how to use priority queue comparator stl c++

void SamplePriorityQueueWithLamda()
{
    // using lambda to compare elements.
    auto compare = [](int lhs, int rhs)
                {
                    return lhs < rhs;
                };

    std::priority_queue<int, std::vector<int>, decltype(compare)> q(compare);

    for(int n : {1,8,5,6,3,4,0,9,7,2})
        q.push(n);


    printQueue(q);
}
Posted by: Guest on April-11-2021
0

how to use comparitor in priority queu in c++

class Node;
bool Compare(Node a, Node b);

std::priority_queue<Node, std::vector<Node>, decltype(&Compare)> openSet(Compare);
Posted by: Guest on June-06-2021

Code answers related to "how do comparotor work in c++ priority queue"

Browse Popular Code Answers by Language