Skip to content

Instantly share code, notes, and snippets.

@nakagami
Created September 11, 2013 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nakagami/6518534 to your computer and use it in GitHub Desktop.
Save nakagami/6518534 to your computer and use it in GitHub Desktop.
A sample code of "container/list".
// http://golang.org/pkg/container/list/
package main
import (
"fmt"
"container/list"
)
func main() {
l := list.New()
e4 := l.PushBack(4)
e1 := l.PushFront(1)
e := l.PushFront(1)
l.Remove(e)
l.InsertBefore("e3", e4)
l.InsertAfter(nil, e1)
fmt.Println("len=", l.Len())
for e := l.Front(); e != nil; e = e.Next() {
fmt.Println(e.Value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment