Skip to content

Commit

Permalink
调整:Distinct的实现方式,改由reflect.DeepEqual比较
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Apr 1, 2024
1 parent b40e6c3 commit 6737f50
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion enumerable.go
Original file line number Diff line number Diff line change
Expand Up @@ -938,10 +938,14 @@ func (receiver Enumerable[T]) Distinct() Enumerable[T] {
defer receiver.lock.RUnlock()

lst := NewList[T]()

for _, item := range *receiver.source {
if !lst.Contains(item) {
if !lst.Where(func(t T) bool { return reflect.DeepEqual(item, t) }).Any() {
lst.Add(item)
}
//if !lst.Contains(item) {
// lst.Add(item)
//}
}
return lst.Enumerable
}
Expand Down

0 comments on commit 6737f50

Please sign in to comment.