- array:优化 `RemoveDuplicateElement` 去重方法

master
李光春 2 years ago
parent 3720c2d88f
commit 0ae92a5c75

@ -18,9 +18,9 @@ func TurnString(ss []string) (s string) {
}
// RemoveDuplicateElement 去重
func RemoveDuplicateElement(ss []string) []string {
result := make([]string, 0, len(ss))
temp := map[string]struct{}{}
func RemoveDuplicateElement[T string | int | int16 | int32](ss []T) []T {
result := make([]T, 0, len(ss))
temp := map[T]struct{}{}
for _, item := range ss {
if _, ok := temp[item]; !ok {
temp[item] = struct{}{}

Loading…
Cancel
Save