queue,deque,priority_queue [英] queue, deque, priority_queue

查看:87
本文介绍了queue,deque,priority_queue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

queue,deque和priority_queue有什么区别?在什么

情况下选择其中一个使用?谢谢你的帮助!

What differences between queue, deque and priority_queue? And under what
situations choose one of them to use? Thanks for your help!

推荐答案

文章< 47_lb.190847
In article <47_lb.190847


0v4.14787426@bgtnsc04-

news.ops.worldnet.att.net>, ne ***** @ hotmail.com 说...
0v4.14787426@bgtnsc04-
news.ops.worldnet.att.net>, ne*****@hotmail.com says...
queue,deque和priority_queue有什么区别?在什么情况下选择其中一个使用?谢谢你的帮助!
What differences between queue, deque and priority_queue? And under what
situations choose one of them to use? Thanks for your help!




有了一个队列,你将项目插入一个并从

另一端提取它们 - 即你只能按照他们插入的
的顺序来解决问题。


使用双端队列,你可以从任何一端插入和/或删除,所以你得到一个

组合的堆栈行为(删除最近插入的项目)

或队列行为(如上所述)。


优先级队列与其中任何一个都不同。使用优先级

队列,您可以指定项目的排序顺序。你

插入物品并删除物品,但是当你移除物品时,你会按照排序顺序获得

。这对于必须完成任务的任务非常方便。当出现需要完成的任务时,您将

放入优先级队列。当你准备好执行任务时,你需要从优先级队列中拉出一个,然后你将获得最高优先级的任务。等待。


-

后来,

杰瑞。


宇宙是一个自己想象的虚构。



With a queue, you insert items at one and and extract them from the
other end -- i.e. you can ONLY get things out in the order in which they
were inserted.

With a deque, you can insert and/or remove from either end, so you get a
combination of stack behavior (remove the most recently inserted item)
or queue behavior (as above).

A priority queue is different from either of these. With a priority
queue, you specify an ordering by which items will be sorted. You
insert items and you remove items, but when you remove items, you get
them in sorted order. This is handy for things like tasks that have to
be completed. When a task arises that will need to be done, you put it
into the priority queue. When you''re ready to carry out a task, you
pull one from the priority queue, and you''ll get the highest priority
task that''s waiting.

--
Later,
Jerry.

The universe is a figment of its own imagination.


Jerry Coffin写道:
Jerry Coffin wrote:
文章< 47_lb.190847
In article <47_lb.190847


这篇关于queue,deque,priority_queue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆