摘要: priority_queue优先队列容器与队列一样,只能从队尾添加(插入)元素,从队头(队首)删除元素。但他有一个特性,就是队列中最大的元素总是位于队首,所以出队时,并非按先进先出的原则进行,而是将当前队列中最大的元素出队。如果要删除中间元素,就要用heap 阅读全文
posted @ 2016-01-06 23:44 飞飞喵 阅读(130) 评论(0) 推荐(0)
摘要: // make_pair example#include // std::pair#include // std::coutint main () { std::pair foo; std::pair bar; foo = std::make_pair (10,20)... 阅读全文
posted @ 2016-01-06 23:28 飞飞喵 阅读(170) 评论(0) 推荐(0)
摘要: // range heap example#include // std::cout#include // std::make_heap, std::pop_heap, std::push_heap, std::sort_heap#include // std::ve... 阅读全文
posted @ 2016-01-06 09:11 飞飞喵 阅读(218) 评论(1) 推荐(0)
摘要: 定义queue对象的示例代码如下:queue q1;queue q2;queue的基本操作有:入队,如例:q.push(x); 将x接到队列的末端。出队,如例:q.pop(); 弹出队列的第一个元素,注意,并不会返回被弹出元素的值。访问队首元素,如例:q.front(),即最早被压入队列的元素。访问... 阅读全文
posted @ 2016-01-06 05:09 飞飞喵 阅读(144) 评论(0) 推荐(0)