栈 队列和优先队列

栈:

    #include<stack>

    stack<int>s;

    入栈:push();

    出栈:pop();

    取栈顶top();

队列:

    #include<queue>

    queue<int>s;

    入队:push();

    出队:pop();

    取队首元素:front();(不删除)

优先队列:

    priority_queue<int>pq;

入队:push();

    出队:pop();

    取队首元素:top();(不删除)

这里取的队首元素是优先级最高的元素,pq是一个数越大优先级越高的优先对列

    priority_queue<int,vector<int>,greater<int> >s;

这里s是一个数越小优先级越高的优先对列

猜你喜欢

转载自blog.csdn.net/acdalao/article/details/80207458