Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

queue

  • PushBack

  • Front

  • Remove

  • see lists

package main

import (
	"container/list"
	"fmt"
)

func main() {
	queue := list.New()

	queue.PushBack("Joe")
	queue.PushBack("Jane")
	queue.PushBack("Mary")
	queue.PushBack("Joe")

	for {
		if queue.Len() == 0 {
			break
		}
		item := queue.Front()
		fmt.Println(item.Value)
		queue.Remove(item)
	}
}
Joe
Jane
Mary
Joe