队列的实际应用是什么? [英] What are practical applications of Queues?

查看:18
本文介绍了队列的实际应用是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

队列在计算机科学中的实际应用是什么.我们在哪里使用它们,为什么?我听说我们在视频游戏和计算机模拟程序中使用它们,是真的吗?为什么?除了这两个领域之外,队列作为数据结构还有哪些实际应用?

What are practical applications of Queues in Computer Science. Where do we use them and why? I heard that we use them in Video Games and Computer Simulation programs, is that true? Why? Apart from these two areas what are other practical applications of Queues as a data structure?

推荐答案

队列用于任何需要有效维护某些实体的先进先出顺序的情况.这些情况确实出现在每种类型的软件开发中.

Queues are used for any situation where you want to efficiently maintain a First-in-first out order on some entities. These situations arise literally in every type of software development.

想象一下,您有一个为成千上万的用户提供文件的网站.您不能为所有请求提供服务,一次只能处理 100 个请求.公平的政策是先到先得:按到达顺序一次发球 100 个.Queue 肯定是最合适的数据结构.

Imagine you have a web-site which serves files to thousands of users. You cannot service all requests, you can only handle say 100 at once. A fair policy would be first-come-first serve: serve 100 at a time in order of arrival. A Queue would definitely be the most appropriate data structure.

同样在多任务操作系统中,CPU 无法一次运行所有作业,因此必须将作业批量化,然后根据某种策略进行调度.同样,在这种情况下,队列可能是一个合适的选择.

Similarly in a multitasking operating system, the CPU cannot run all jobs at once, so jobs must be batched up and then scheduled according to some policy. Again, a queue might be a suitable option in this case.

这篇关于队列的实际应用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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