mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
add iterate example for glist; improve variable name for ghttp.Server
This commit is contained in:
@ -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]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user