blob: 362178401716d7ffffa896ed0b044ef04ecc1541 [file] [log] [blame]
Colin Cross7bb052a2015-02-03 12:59:37 -08001// Copyright 2013 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package list_test
6
7import (
8 "container/list"
9 "fmt"
10)
11
12func Example() {
13 // Create a new list and put some numbers in it.
14 l := list.New()
15 e4 := l.PushBack(4)
16 e1 := l.PushFront(1)
17 l.InsertBefore(3, e4)
18 l.InsertAfter(2, e1)
19
20 // Iterate through list and print its contents.
21 for e := l.Front(); e != nil; e = e.Next() {
22 fmt.Println(e.Value)
23 }
24
25 // Output:
26 // 1
27 // 2
28 // 3
29 // 4
30}