Slice: CountV2 (#18)

Use generic instead of reflection
This commit is contained in:
donutloop authored and GitHub committed 2022-01-09 22:15:03 +08:00
1 parent c4b4cb1173
commit 7b9a8a55e7
3 files changed
+14 -15

No files matched your search

+1 -1
View File
@@ -420,7 +420,7 @@ func Union(slices ...interface{}) interface{} //Union creates a slice of unique
func UpdateByIndex(slice interface{}, index int, value interface{}) (interface{}, error) //update the slice element at index.
func Without(slice interface{}, values ...interface{}) interface{} //creates a slice excluding all given values
func GroupBy(slice, function interface{}) (interface{}, interface{}) // groups slice into two categories
func Count(slice, function interface{}) int // Count iterates over elements of slice, returns a count of all matched elements
Count[T any](slice []T, fn func(index int, t T) bool) int // Count iterates over elements of slice, returns a count of all matched elements
```
#### 10. strutil is for processing string