MCPcopy Create free account
hub / github.com/sourcegraph/conc / ExampleIterator

Function ExampleIterator

iter/iter_test.go:12–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10)
11
12func ExampleIterator() {
13 input := []int{1, 2, 3, 4}
14 iterator := Iterator[int]{
15 MaxGoroutines: len(input) / 2,
16 }
17
18 iterator.ForEach(input, func(v *int) {
19 if *v%2 != 0 {
20 *v = -1
21 }
22 })
23
24 fmt.Println(input)
25 // Output:
26 // [-1 2 -1 4]
27}
28
29func TestIterator(t *testing.T) {
30 t.Parallel()

Callers

nothing calls this directly

Calls 1

ForEachMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…