placeybordeaux
placeybordeaux

Reputation: 2216

Is there any way to make Go's channels behave like a stack

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?

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

Upvotes: 4

Views: 2066

Answers (1)

thwd
thwd

Reputation: 24818

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

Upvotes: 6

Related Questions