ここから取得http://www.cplusplus.com/reference/queue/priority_queue/
Compare
A binary predicate that takes two elements (of type T) as arguments and returns a bool.
The expression comp(a,b), where comp is an object of this type and a and b are elements in the container, shall return true if a is considered to go before b in the strict weak ordering the function defines.
比較関数を書くとき、どの要素がキューで長く待っているかを知る方法はありますか?
新しい要素が挿入されるたびに比較関数が呼び出されると仮定すると、「a」は常に新しいアイテムになり、「b」はすでにキューにある要素になりますか? それとも違う働きをしますか?
私の考えは、次のようなものでした:
bool my_class::operator()(const my_class &a, const my_class &b) {
//Lower priority comes first
return (a.get_priority() < b.get_priority());
}
'a' と 'b' の優先順位が同じ場合、'b' が優先順位を与えられます。
std::queue がどのように機能するか、および目標を達成する方法についてフィードバックをお寄せいただきありがとうございます。