本文介绍了有什么办法可以使Go的频道像堆栈一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,默认情况下,转到频道的行为就像一个队列,先进先出。

Go channels by default behave like a queue as far as I can tell, first in first out. Is there any way to change them to work last in first out?

基本上我在做一个搜索,想用DFS代替BFS来解决内存限制。

Basically I am doing a search and want to do DFS instead of BFS for memory constraints.

推荐答案

否,这是不可能的-通道始终是FIFO。您可以使用软件包。

No, this is not possible - channels are always FIFO. You could use package container/heap.

这篇关于有什么办法可以使Go的频道像堆栈一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 05:51