github.com/goplus/igop@v0.25.0/pkg/maps/go121_export.go (about)

     1  // export by github.com/goplus/igop/cmd/qexp
     2  
     3  //go:build go1.21
     4  // +build go1.21
     5  
     6  package maps
     7  
     8  import (
     9  	_ "maps"
    10  	"reflect"
    11  	_ "unsafe"
    12  
    13  	"github.com/goplus/igop"
    14  )
    15  
    16  func init() {
    17  	igop.RegisterPackage(&igop.Package{
    18  		Name:       "maps",
    19  		Path:       "maps",
    20  		Deps:       map[string]string{},
    21  		Interfaces: map[string]reflect.Type{},
    22  		NamedTypes: map[string]reflect.Type{},
    23  		AliasTypes: map[string]reflect.Type{},
    24  		Vars:       map[string]reflect.Value{},
    25  		Funcs: map[string]reflect.Value{
    26  			"clone": reflect.ValueOf(_clone),
    27  		},
    28  		TypedConsts:   map[string]igop.TypedConst{},
    29  		UntypedConsts: map[string]igop.UntypedConst{},
    30  		Source:        source,
    31  	})
    32  }
    33  
    34  //go:linkname _clone maps.clone
    35  func _clone(m any) any
    36  
    37  var source = "package maps\n\nfunc Equal[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool {\n\tif len(m1) != len(m2) {\n\t\treturn false\n\t}\n\tfor k, v1 := range m1 {\n\t\tif v2, ok := m2[k]; !ok || v1 != v2 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc EqualFunc[M1 ~map[K]V1, M2 ~map[K]V2, K comparable, V1, V2 any](m1 M1, m2 M2, eq func(V1, V2) bool) bool {\n\tif len(m1) != len(m2) {\n\t\treturn false\n\t}\n\tfor k, v1 := range m1 {\n\t\tif v2, ok := m2[k]; !ok || !eq(v1, v2) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc clone(m any) any\n\nfunc Clone[M ~map[K]V, K comparable, V any](m M) M {\n\n\tif m == nil {\n\t\treturn nil\n\t}\n\treturn clone(m).(M)\n}\n\nfunc Copy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {\n\tfor k, v := range src {\n\t\tdst[k] = v\n\t}\n}\n\nfunc DeleteFunc[M ~map[K]V, K comparable, V any](m M, del func(K, V) bool) {\n\tfor k, v := range m {\n\t\tif del(k, v) {\n\t\t\tdelete(m, k)\n\t\t}\n\t}\n}\n"