Design pattern for managing queues and stacks?

拈花ヽ惹草 提交于 2020-02-21 06:21:59

问题


Is there a design pattern for managing a queue or a stack? For example, we are looking to manage a list of tasks. These tasks will be added to a group queue, users will then be able to pull off the queue and add them to their personal queue.


回答1:


Design patterns can use queues and stacks, but the queues and stacks themselves don't really implement a design pattern, they implement an interface.

Queues are typically FIFO while stacks are LIFO.

Since many users might be using the data structures simultaneously, you should use proper synchronization to avoid concurrency issues.

Are you looking for concurrency-related design patterns to use?




回答2:


Most frameworks provide some kind of queue and/or stack implementations. E.g. in .NET - System.Collections.Generic.Queue and System.Collections.Generic.Stack



来源:https://stackoverflow.com/questions/1703095/design-pattern-for-managing-queues-and-stacks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!