mercredi 23 septembre 2015

The reason of using `std::greater` for creating min heap via `priority_queue`

I am wondering why for creating a min heap using the priority_queue, the std::greater should be used?

std::priority_queue<T, std::vector<T>, std::greater<T> > min_heap;

To me, since the smallest value is always located at the top of the heap, the employed class should be std::less

Aucun commentaire:

Enregistrer un commentaire