github.com/zhongdalu/gf@v1.0.0/g/container/glist/glist_example_test.go (about) 1 // Copyright 2018 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/zhongdalu/gf. 6 7 package glist_test 8 9 import ( 10 "fmt" 11 "github.com/zhongdalu/gf/g/container/glist" 12 ) 13 14 func Example_basic() { 15 n := 10 16 l := glist.New() 17 for i := 0; i < n; i++ { 18 l.PushBack(i) 19 } 20 fmt.Println(l.Len()) 21 fmt.Println(l.FrontAll()) 22 fmt.Println(l.BackAll()) 23 for i := 0; i < n; i++ { 24 fmt.Print(l.PopFront()) 25 } 26 l.Clear() 27 fmt.Println() 28 fmt.Println(l.Len()) 29 30 // Output: 31 //10 32 //[0 1 2 3 4 5 6 7 8 9] 33 //[9 8 7 6 5 4 3 2 1 0] 34 //0123456789 35 //0 36 }