Vendor main dependencies.
This commit is contained in:
parent
49a09ab7dd
commit
dd5e3fba01
2738 changed files with 1045689 additions and 0 deletions
46
vendor/github.com/BurntSushi/ty/fun/map.go
generated
vendored
Normal file
46
vendor/github.com/BurntSushi/ty/fun/map.go
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
package fun
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/BurntSushi/ty"
|
||||
)
|
||||
|
||||
// Keys has a parametric type:
|
||||
//
|
||||
// func Keys(m map[A]B) []A
|
||||
//
|
||||
// Keys returns a list of the keys of `m` in an unspecified order.
|
||||
func Keys(m interface{}) interface{} {
|
||||
chk := ty.Check(
|
||||
new(func(map[ty.A]ty.B) []ty.A),
|
||||
m)
|
||||
vm, tkeys := chk.Args[0], chk.Returns[0]
|
||||
|
||||
vkeys := reflect.MakeSlice(tkeys, vm.Len(), vm.Len())
|
||||
for i, vkey := range vm.MapKeys() {
|
||||
vkeys.Index(i).Set(vkey)
|
||||
}
|
||||
return vkeys.Interface()
|
||||
}
|
||||
|
||||
// Values has a parametric type:
|
||||
//
|
||||
// func Values(m map[A]B) []B
|
||||
//
|
||||
// Values returns a list of the values of `m` in an unspecified order.
|
||||
func Values(m interface{}) interface{} {
|
||||
chk := ty.Check(
|
||||
new(func(map[ty.A]ty.B) []ty.B),
|
||||
m)
|
||||
vm, tvals := chk.Args[0], chk.Returns[0]
|
||||
|
||||
vvals := reflect.MakeSlice(tvals, vm.Len(), vm.Len())
|
||||
for i, vkey := range vm.MapKeys() {
|
||||
vvals.Index(i).Set(vm.MapIndex(vkey))
|
||||
}
|
||||
return vvals.Interface()
|
||||
}
|
||||
|
||||
// func MapMerge(m1, m2 interface{}) interface{} {
|
||||
// }
|
Loading…
Add table
Add a link
Reference in a new issue