mirror of
https://gitee.com/johng/gf.git
synced 2024-12-02 12:17:53 +08:00
Implemented TreeMap Example
This commit is contained in:
parent
8ea4b71e7a
commit
b58c5311d0
@ -8,6 +8,7 @@ package gmap_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/util/gutil"
|
||||
|
||||
"github.com/gogf/gf/v2/container/gmap"
|
||||
)
|
||||
@ -280,3 +281,31 @@ func ExampleNewListMapFrom() {
|
||||
// {"key1":"var1","key2":"var2"}
|
||||
// {"key1":"var1","key2":"var2"}
|
||||
}
|
||||
|
||||
func ExampleNewTreeMap() {
|
||||
m := gmap.NewTreeMap(gutil.ComparatorString)
|
||||
|
||||
m.Set("key2", "var2")
|
||||
m.Set("key1", "var1")
|
||||
|
||||
fmt.Println(m.Map())
|
||||
|
||||
// Output:
|
||||
// map[key1:var1 key2:var2]
|
||||
}
|
||||
|
||||
func ExampleNewTreeMapFrom() {
|
||||
m := gmap.NewTreeMap(gutil.ComparatorString)
|
||||
|
||||
m.Set("key2", "var2")
|
||||
m.Set("key1", "var1")
|
||||
|
||||
fmt.Println(m.Map())
|
||||
|
||||
n := gmap.NewListMapFrom(m.Map(), true)
|
||||
fmt.Println(n.Map())
|
||||
|
||||
// Output:
|
||||
// map[key1:var1 key2:var2]
|
||||
// map[key1:var1 key2:var2]
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
package gmap
|
Loading…
Reference in New Issue
Block a user