Skip to content

GROOVY-11606: Lazy findAll, collect, collectMany (alternative proposa… #2184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ public static <T> List<List<T>> collate(T[] self, int size, int step, boolean ke
* @since 2.5.0
*/
public static <E, T> List<T> collect(E[] self, @ClosureParams(FirstParam.Component.class) Closure<T> transform) {
return DefaultGroovyMethods.collect(new ArrayIterator<>(self), transform);
return DefaultGroovyMethods.collect(new ArrayIterable<>(self), transform);
}

/**
Expand Down Expand Up @@ -1120,7 +1120,7 @@ public static Iterator<float[]> columns(float[][] self) {
* <pre class="groovyTestCase">
* int[][] nums = [[1, 2], [10, 20]]
* assert nums.transpose() == nums.columns().toList()
* assert nums.columns().collect{ int[] col -> col.sum() } == [11, 22]
* assert nums.columns().collect{ int[] col -> col.sum() }.toList() == [11, 22]
* </pre>
*
* @param self an int[][]
Expand All @@ -1135,7 +1135,7 @@ public static Iterator<int[]> columns(int[][] self) {
* <pre class="groovyTestCase">
* long[][] nums = [[1L, 2L], [10L, 20L]]
* assert nums.transpose() == nums.columns().toList()
* assert nums.columns().collect{ long[] col -> col.sum() } == [11L, 22L]
* assert nums.columns().collect{ long[] col -> col.sum() }.toList() == [11L, 22L]
* </pre>
*
* @param self a long[][]
Expand Down Expand Up @@ -2623,7 +2623,7 @@ public static <T> List<Number> findIndexValues(T[] self, @ClosureParams(FirstPar
* @since 2.5.0
*/
public static <T> List<Number> findIndexValues(T[] self, Number startIndex, @ClosureParams(FirstParam.Component.class) Closure<?> condition) {
return DefaultGroovyMethods.findIndexValues(new ArrayIterator<>(self), startIndex, condition);
return DefaultGroovyMethods.findIndexValues(new ArrayIterable<>(self), startIndex, condition);
}

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -2762,7 +2762,7 @@ public static <T> Collection<T> findResults(T[] self) {
* @since 2.5.0
*/
public static <T, U> Collection<T> findResults(U[] self, @ClosureParams(FirstParam.Component.class) Closure<T> filteringTransform) {
return DefaultGroovyMethods.findResults(new ArrayIterator<>(self), filteringTransform);
return DefaultGroovyMethods.findResults(new ArrayIterable<>(self), filteringTransform);
}

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -9489,7 +9489,7 @@ public static Iterator<Tuple2<Float, Float>> zip(float[] self, float[] other) {
* <pre class="groovyTestCase">
* int[] small = [1, 2, 3]
* int[] large = [100, 200, 300]
* assert [101, 202, 303] == small.zip(large).collect{ a, b -> a + b }
* assert [101, 202, 303] == small.zip(large).collect{ a, b -> a + b }.toList()
* assert [small, large].transpose() == small.zip(large).toList()
* </pre>
*
Expand All @@ -9506,7 +9506,7 @@ public static Iterator<Tuple2<Integer, Integer>> zip(int[] self, int[] other) {
* <pre class="groovyTestCase">
* long[] small = [1L, 2L, 3L]
* long[] large = [100L, 200L, 300L]
* assert [101L, 202L, 303L] == small.zip(large).collect{ a, b -> a + b }
* assert [101L, 202L, 303L] == small.zip(large).collect{ a, b -> a + b }.toList()
* assert [small, large].transpose() == small.zip(large).toList()
* </pre>
*
Expand Down
Loading