c++模板中关于priorityqueue的声明在queue头文件中,因此使用时要#include
Construct
重载两种形式
priority_queue<int>;
priority_queue<valuetype,container,bool compare>;
Feature
- based on container;
- ‘compare’ is a functor;
example:
class g {
public:
bool operator() (int a,int b){
return a > b;
}
};
priority_queue<int,vector<int>, g > a;
for (int i = 0; i < 10; i++)a.emplace(i);
while (!a.empty()) {
cout << a.top(); a.pop();
}
Iterator
try and failed(dog).
Capaticy
size();
empty();
Modify
push();
pop();
emplace();
top();
end;