Group: comp.lang.c++
From: Kai-Uwe Bux
Date: Thursday, April 10, 2008 7:10 PM
Subject: Re: Priority queue question

Kelvin Moss wrote:

[snip]
> Perhaps I was not clear in my question. I meant to know that why does
> the greatest element get picked with the less <> function object?
> Won't it have been more intuitive to return the least element with
> less<> function object? Or may be I am missing something?

Intuitively, a priority queue is supposed to retrieve elements starting from
highest down to lowest priority. On the other hand, the standard uses
std::less<> by default to define the order relation on a type. Therefore,
the priority queue uses std::less<> to figure out the element with the top
priority.


Best

Kai-Uwe Bux

Safety Articles | Usenet Groups | Usenet News | Bluegrass