mirror of
https://github.com/unti-io/go-utils.git
synced 2026-04-22 15:37:20 +08:00
v1.9.11
This commit is contained in:
+3
-3
@@ -7,9 +7,9 @@ func HasDuplicate[T comparable](slice []T) bool {
|
||||
seen := make(map[T]struct{}, len(slice))
|
||||
|
||||
for _, v := range slice {
|
||||
if _, exists := seen[v]; exists {
|
||||
return true // 发现重复
|
||||
}
|
||||
// 发现重复
|
||||
if _, exists := seen[v]; exists { return true }
|
||||
// 记录已见过的元素
|
||||
seen[v] = struct{}{}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user