Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ func testSetConcurrency(t *testing.T, set Set[int]) {
for i := range (base + 1) * 100 {
set.Add(i)
}
finished.Done()
},
func(base int) {
var x int
Expand All @@ -531,7 +530,6 @@ func testSetConcurrency(t *testing.T, set Set[int]) {
x = set.Cardinality()
}
_ = x
finished.Done()
},
func(base int) {
var x bool
Expand All @@ -541,15 +539,13 @@ func testSetConcurrency(t *testing.T, set Set[int]) {
x = set.Contains(i)
}
_ = x
finished.Done()
},
func(base int) {
started <- struct{}{}
<-start
for i := range (base + 1) * 100 {
set.Remove(i)
}
finished.Done()
},
func(base int) {
other := New[int]()
Expand All @@ -560,7 +556,6 @@ func testSetConcurrency(t *testing.T, set Set[int]) {
<-start
AppendSeq(other, set.Iterator)
RemoveSeq(set, other.Iterator)
finished.Done()
},
func(base int) {
var x int
Expand All @@ -572,14 +567,14 @@ func testSetConcurrency(t *testing.T, set Set[int]) {
}
}
_ = x
finished.Done()
},
}
count := 20
for i := range count {
finished.Add(len(goroutines))
for j := range len(goroutines) {
go goroutines[j](i)
finished.Go(func() {
goroutines[j](i)
})
}
}

Expand Down
6 changes: 3 additions & 3 deletions sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (s *SyncMap[M]) Pop() (M, bool) {
var m M
var ok bool

s.m.Range(func(key, _ interface{}) bool {
s.m.Range(func(key, _ any) bool {
if _, ok = s.m.LoadAndDelete(key); ok {
m = key.(M)
ok = true
Expand All @@ -88,7 +88,7 @@ func (s *SyncMap[M]) Cardinality() int {
return 0
}
var n int
s.m.Range(func(_, _ interface{}) bool {
s.m.Range(func(_, _ any) bool {
n++
return true
})
Expand All @@ -98,7 +98,7 @@ func (s *SyncMap[M]) Cardinality() int {
// Iterator yields all elements in the set. It is safe to call concurrently with other methods, but the order and
// behavior is undefined, as per [sync.Map]'s `Range`.
func (s *SyncMap[M]) Iterator(yield func(M) bool) {
s.m.Range(func(key, _ interface{}) bool {
s.m.Range(func(key, _ any) bool {
return yield(key.(M))
})
}
Expand Down
Loading