是否有队列实现? [英] Is there a queue implementation?

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

问题描述

任何人都可以为Go容器提供简单快速的FIF /队列,Go有3个不同的容器: heap list vector 。哪一个更适合实现一个队列?

解决方案

矢量或列表都可以工作,但矢量可能是要走的路。我这样说是因为向量可能分配的次数少于列表和垃圾回收(在当前的Go实现中)相当昂贵。尽管如此,在一个小程序中它可能无所谓。


Can anyone suggest Go container for simple and fast FIF/queue, Go has 3 different containers: heap, list and vector. Which one is more suitable to implement a queue?

解决方案

Either vector or list should work, but vector is probably the way to go. I say this because vector will probably allocate less often than list and garbage collection (in the current Go implementation) is fairly expensive. In a small program it probably won't matter, though.

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

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