@@ -716,7 +716,7 @@ public class GParsPoolUtil {
716
716
* This allows further parallel processing operations on the collection to chain and so effectively leverage the underlying
717
717
* ParallelArray implementation.
718
718
*/
719
- public static Object getParallel (Object collection ) {
719
+ public static PAWrapper getParallel (Object collection ) {
720
720
return getParallel(createCollection(collection))
721
721
}
722
722
@@ -761,7 +761,7 @@ abstract class AbstractPAWrapper<T> {
761
761
* @return The product of reduction
762
762
*/
763
763
public final T reduce (Closure cl ) {
764
- pa. reduce(cl as Reducer , null )
764
+ pa. all() . reduce(cl as Reducer , null )
765
765
}
766
766
767
767
/**
@@ -844,26 +844,16 @@ abstract class AbstractPAWrapper<T> {
844
844
* @param A closure indicating whether to propagate the given element into the filtered collection
845
845
* @return A collection holding the allowed values
846
846
*/
847
- public abstract AbstractPAWrapper filter (Closure cl )
847
+ public AbstractPAWrapper filter (Closure cl ) {
848
+ new PAWrapper (pa. withFilter({cl(it)} as Predicate ))
849
+ }
848
850
}
849
851
850
852
/**
851
853
* The default ParallelArray wrapper class
852
854
*/
853
855
final class PAWrapper <T> extends AbstractPAWrapper {
854
-
855
- def PAWrapper (final pa ) {
856
- super (pa)
857
- }
858
-
859
- /**
860
- * Filters concurrently elements in the collection based on the outcome of the supplied function on each of the elements.
861
- * @param A closure indicating whether to propagate the given element into the filtered collection
862
- * @return A collection holding the allowed values
863
- */
864
- public PAWrapper filter (Closure cl ) {
865
- new PAWrapper (pa. withFilter({cl(it)} as Predicate ). all())
866
- }
856
+ def PAWrapper (final pa ) { super (pa) }
867
857
}
868
858
869
859
/**
@@ -880,7 +870,7 @@ final class MappedPAWrapper<T> extends AbstractPAWrapper {
880
870
* @param A closure indicating whether to propagate the given element into the filtered collection
881
871
* @return A collection holding the allowed values
882
872
*/
883
- public PAWrapper filter (Closure cl ) {
884
- new PAWrapper (pa. all(). withFilter({cl(it)} as Predicate ). all() )
873
+ public final AbstractPAWrapper filter (Closure cl ) {
874
+ new PAWrapper (pa. all(). withFilter({cl(it)} as Predicate ))
885
875
}
886
876
}
0 commit comments