mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
comment without func
This commit is contained in:
@@ -566,18 +566,18 @@ func reverseSlice(slice interface{}) {
|
||||
}
|
||||
|
||||
// Without creates a slice excluding all given values
|
||||
func Without[T comparable](slice []T, values ...T) []T {
|
||||
var indexes []int
|
||||
for i := 0; i < len(slice); i++ {
|
||||
if !Contain(values, slice[i]) {
|
||||
indexes = append(indexes, i)
|
||||
}
|
||||
}
|
||||
// func Without[T comparable](slice []T, values ...T) []T {
|
||||
// var indexes []int
|
||||
// for i := 0; i < len(slice); i++ {
|
||||
// if !Contain(values, slice[i]) {
|
||||
// indexes = append(indexes, i)
|
||||
// }
|
||||
// }
|
||||
|
||||
res := make([]T, len(indexes), len(indexes))
|
||||
for i, v := range indexes {
|
||||
res[i] = slice[v]
|
||||
}
|
||||
// res := make([]T, len(indexes), len(indexes))
|
||||
// for i, v := range indexes {
|
||||
// res[i] = slice[v]
|
||||
// }
|
||||
|
||||
return res
|
||||
}
|
||||
// return res
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user