本文介绍了有队列实现吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以为简单快速的 FIF/队列推荐 Go 容器,Go 有 3 个不同的容器:heap
、list
和 vector
.哪个更适合实现队列?
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?
推荐答案
vector 或 list 都可以,但 vector 可能是要走的路.我这样说是因为 vector 的分配频率可能比 list 少,而且垃圾收集(在当前的 Go 实现中)相当昂贵.不过,在一个小程序中,这可能无关紧要.
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.
这篇关于有队列实现吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!