Tôi muốn làm điều này:Làm thế nào để sử dụng một STL priority_queue + so sánh với một nhà xây dựng cụ thể?
#include <queue>
#include <set>
class Comparator
{
public:
Comparator(SomeObject& rTool) : mrTools(rTool) {}
bool operator()(const std::string& a, const std::string& b)
{
return mrTools.doSomething(a,b);
}
private:
SomeObject& mrTools;
}
std::priority_queue<std::string, std::set<std::string>, Comparator> queue;
//<- this doesn't compile
Làm thế nào tôi có thể initalize hàng đợi này cung cấp sánh với các tài liệu tham khảo cần thiết trong các nhà xây dựng?
Một 'priority_queue' có ít chức năng hơn' bộ'. Lý do duy nhất (nhưng có thể rất tốt) để ưu tiên 'priority_queue' là hiệu quả. –