gitee.com/quant1x/num@v0.3.2/logic_all.go (about) 1 package num 2 3 import ( 4 "gitee.com/quant1x/num/x64" 5 ) 6 7 // All 全部为真 8 func All[T Number | ~bool](x []T) bool { 9 switch vs := any(x).(type) { 10 case []bool: 11 return x64.All(vs) 12 case []int8: 13 return __all_go(vs) 14 case []uint8: 15 return __all_go(vs) 16 case []int16: 17 return __all_go(vs) 18 case []uint16: 19 return __all_go(vs) 20 case []int32: 21 return __all_go(vs) 22 case []uint32: 23 return __all_go(vs) 24 case []int64: 25 return __all_go(vs) 26 case []uint64: 27 return __all_go(vs) 28 case []int: 29 return __all_go(vs) 30 case []uint: 31 return __all_go(vs) 32 case []uintptr: 33 return __all_go(vs) 34 case []float32: 35 return __all_go(vs) 36 case []float64: 37 return __all_go(vs) 38 } 39 return false 40 } 41 42 func __all_go[T Number](x []T) bool { 43 for i := 0; i < len(x); i++ { 44 if x[i] == 0 { 45 return false 46 } 47 } 48 return true 49 }