diff --git a/container/glist/glist_example_test.go b/container/glist/glist_example_test.go index cdbdf3fc5..b8d852408 100644 --- a/container/glist/glist_example_test.go +++ b/container/glist/glist_example_test.go @@ -63,6 +63,20 @@ func Example_iterate() { fmt.Println() + // iterate reading from head using IteratorAsc. + l.IteratorAsc(func(e *glist.Element) bool { + fmt.Print(e.Value) + return true + }) + fmt.Println() + // iterate reading from head using IteratorDesc. + l.IteratorDesc(func(e *glist.Element) bool { + fmt.Print(e.Value) + return true + }) + + fmt.Println() + // iterate writing from head. l.LockFunc(func(list *list.List) { length := list.Len() @@ -80,5 +94,7 @@ func Example_iterate() { //output: //12345678910 //10987654321 + //12345678910 + //10987654321 //[1,2,3,4,5,"M",7,8,9,10] }