Is there a queue implementation?

后端 未结 14 1179
时光取名叫无心
时光取名叫无心 2020-12-23 02:14

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

14条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-23 02:53

    Surprised to see no one has suggested buffered channels yet, for size bound FIFO Queue anyways.

    //Or however many you might need + buffer.
    c := make(chan int, 300)
    
    //Push
    c <- value
    
    //Pop
    x <- c
    

提交回复
热议问题