stl优先级队列基于较低的值先

编程入门 行业动态 更新时间:2024-10-08 08:32:11
本文介绍了stl优先级队列基于较低的值先的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个stl优先级队列的问题。我希望有优先级队列在增加的顺序,这是递减的默认值。有任何方法在优先级队列这样做。

I have a problem with stl priority queue.I want to have the priority queue in the increasing order,which is decreasing by default.Is there any way to do this in priority queue.

构建stl优先级队列的复杂性是什么。如果我在数组中使用快速排序,需要O(nlgn),它的复杂性类似于使用优先队列

And what is the complexity of building stl priority queue.If i use quick sort in an array which takes O(nlgn) is its complexity is similar to using priority queue???

Plz有人ans.Advanced thanx。

Plz someone ans.Advanced thanx.

推荐答案

使用不同的比较器作为 std :: priority_queue 。

Use a different comparator as the 3rd template argument of std::priority_queue.

priority_queue是一个容器适配器,适用于您定义的任何序列。插入的性能等于 std :: push_heap 操作,并取对数时间。因此,在完成所有插入之后排序的复杂性不相等。如果你插入一个固定的数量,并在队列后工作向量和单个排序可能会更有效率。

priority_queue is a container adaptor that works on any sequence you define. The performance of insertion is equal to the std::push_heap operation and takes logarithmic time. So the complexity to sorting after all insertions are done isn't equal. If you insert a fixed amount and work the queue afterwards a vector and a single sort could be more efficient.

更多推荐

stl优先级队列基于较低的值先

本文发布于:2023-11-29 06:09:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1645563.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:优先级   队列   较低   stl

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!