public class GParsPoolUtil
extends java.lang.Object
GParsPool
Modifier and Type | Field and Description |
---|---|
private static GeneralTimer |
timer
Allows timeouts for async operations
|
Constructor and Description |
---|
GParsPoolUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
anyParallel(java.util.Collection collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static boolean |
anyParallel(java.util.Map collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied map and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static boolean |
anyParallel(java.lang.Object collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static void |
asConcurrent(java.lang.Object collection,
groovy.lang.Closure code)
Makes the collection concurrent for the passed-in block of code.
|
static groovy.lang.Closure |
async(groovy.lang.Closure cl)
Creates an asynchronous variant of the supplied closure, which, when invoked returns a future for the potential return value
|
static groovy.lang.Closure |
asyncFun(groovy.lang.Closure original)
Creates an asynchronous and composable variant of the supplied closure, which, when invoked returns a DataflowVariable for the potential return value
|
static groovy.lang.Closure |
asyncFun(groovy.lang.Closure original,
boolean blocking)
Creates an asynchronous and composable variant of the supplied closure, which, when invoked returns a DataflowVariable for the potential return value
|
static groovy.lang.Closure |
asyncFun(groovy.lang.Closure original,
FJPool pool)
Creates an asynchronous and composable variant of the supplied closure, which, when invoked returns a DataflowVariable for the potential return value
|
static groovy.lang.Closure |
asyncFun(groovy.lang.Closure original,
FJPool pool,
boolean blocking)
Creates an asynchronous and composable variant of the supplied closure, which, when invoked returns a DataflowVariable for the potential return value
|
static <T> java.util.concurrent.Future<T> |
callAsync(groovy.lang.Closure<T> cl,
java.lang.Object... args)
Calls a closure in a separate thread supplying the given arguments, returning a future for the potential return value.
|
static <T> java.util.concurrent.Future<T> |
callParallel(groovy.lang.Closure<T> task)
schedules the supplied closure for processing in the underlying thread pool.
|
static <T> java.util.concurrent.Future<T> |
callTimeoutAsync(groovy.lang.Closure<T> cl,
groovy.time.Duration timeout,
java.lang.Object... args)
Calls a closure in a separate thread supplying the given arguments, returning a future for the potential return value.
|
static <T> java.util.concurrent.Future<T> |
callTimeoutAsync(groovy.lang.Closure<T> cl,
long timeout,
java.lang.Object... args)
Calls a closure in a separate thread supplying the given arguments, returning a future for the potential return value.
|
static <T> java.util.List<T> |
collectManyParallel(java.util.Collection collection,
groovy.lang.Closure<java.util.Collection<? extends T>> projection)
Creates a Parallel Array out of the supplied collection/object and invokes the withMapping() method using the supplied
projection closure as the transformation operation. |
static <T> java.util.List<T> |
collectManyParallel(java.util.Map collection,
groovy.lang.Closure<java.util.Collection<? extends T>> projection)
Creates a Parallel Array out of the supplied collection/object and invokes the withMapping() method using the supplied
projection closure as the transformation operation. |
static <T> java.util.List<T> |
collectManyParallel(java.lang.Object collection,
groovy.lang.Closure<java.util.Collection<? extends T>> projection)
Creates a Parallel Array out of the supplied collection/object and invokes the withMapping() method using the supplied
projection closure as the transformation operation. |
static <T> java.util.Collection<T> |
collectParallel(java.util.Collection collection,
groovy.lang.Closure<? extends T> cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withMapping() method using the supplied
closure as the transformation operation.
|
static <T> java.util.Collection<T> |
collectParallel(java.util.Map collection,
groovy.lang.Closure<? extends T> cl)
Creates a Parallel Array out of the supplied map and invokes the withMapping() method using the supplied
closure as the transformation operation.
|
static <T> java.util.Collection<T> |
collectParallel(java.lang.Object collection,
groovy.lang.Closure<? extends T> cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withMapping() method using the supplied
closure as the transformation operation.
|
static int |
countParallel(java.util.Collection collection,
groovy.lang.Closure filter)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
rule as the filter predicate.
|
static int |
countParallel(java.util.Collection collection,
java.lang.Object filter)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
rule as the filter predicate.
|
static int |
countParallel(java.lang.Object collection,
groovy.lang.Closure filter)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
rule as the filter predicate.
|
static int |
countParallel(java.lang.Object collection,
java.lang.Object filter)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
rule as the filter predicate.
|
private static <K,V> ParallelArray<java.util.Map.Entry<K,V>> |
createPA(java.util.Map<K,V> collection,
jsr166y.ForkJoinPool pool) |
static <T> java.util.Collection<T> |
eachParallel(java.util.Collection<T> collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withMapping() method using the supplied
closure as the transformation operation.
|
static <K,V> java.util.Map<K,V> |
eachParallel(java.util.Map<K,V> collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied map and invokes the withMapping() method using the supplied
closure as the transformation operation.
|
static <T> T |
eachParallel(T collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withMapping() method using the supplied
closure as the transformation operation.
|
static <T> java.util.Collection<T> |
eachWithIndexParallel(java.util.Collection<T> collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withMapping() method using the supplied
closure as the transformation operation.
|
static <K,V> java.util.Map<K,V> |
eachWithIndexParallel(java.util.Map<K,V> collection,
groovy.lang.Closure cl)
Does parallel eachWithIndex on maps
|
static <T> T |
eachWithIndexParallel(T collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withMapping() method using the supplied
closure as the transformation operation.
|
static boolean |
everyParallel(java.util.Collection collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static boolean |
everyParallel(java.util.Map collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied map and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static boolean |
everyParallel(java.lang.Object collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static <T> java.util.Collection<T> |
findAllParallel(java.util.Collection<T> collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static <K,V> java.util.Map<K,V> |
findAllParallel(java.util.Map<K,V> collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied map and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static java.util.Collection<java.lang.Object> |
findAllParallel(java.lang.Object collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static <T> T |
findAnyParallel(java.util.Collection<T> collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static <K,V> java.util.Map.Entry<K,V> |
findAnyParallel(java.util.Map<K,V> collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied map and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static java.lang.Object |
findAnyParallel(java.lang.Object collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static <T> T |
findParallel(java.util.Collection<T> collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static <K,V> java.util.Map.Entry<K,V> |
findParallel(java.util.Map<K,V> collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied map and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static java.lang.Object |
findParallel(java.lang.Object collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
closure as the filter predicate.
|
static <T> T |
foldParallel(java.util.Collection<T> collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes its reduce() method using the supplied
closure as the reduction operation.
|
static <T> T |
foldParallel(java.util.Collection<T> collection,
T seed,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes its reduce() method using the supplied
closure as the reduction operation.
|
static java.lang.Object |
foldParallel(java.lang.Object collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes its reduce() method using the supplied
closure as the reduction operation.
|
static java.lang.Object |
foldParallel(java.lang.Object collection,
java.lang.Object seed,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes its reduce() method using the supplied
closure as the reduction operation.
|
static <T> groovyx.gpars.pa.PAWrapper<T> |
getParallel(java.util.Collection<T> collection)
Creates a PAWrapper around a ParallelArray wrapping the elements of the original collection.
|
static groovyx.gpars.pa.PAWrapper |
getParallel(java.lang.Object collection)
Creates a PAWrapper around a ParallelArray wrapping the elements of the original collection.
|
static <T> ParallelArray<T> |
getParallelArray(java.util.Collection<T> collection)
Creates a ParallelArray wrapping the elements of the original collection.
|
static ParallelArray |
getParallelArray(java.lang.Object collection)
Creates a ParallelArray wrapping the elements of the original collection.
|
static <T> groovy.lang.Closure<T> |
gmemoize(groovy.lang.Closure<T> cl)
Creates a caching variant of the supplied closure.
|
static <T> groovy.lang.Closure<T> |
gmemoizeAtLeast(groovy.lang.Closure<T> cl,
int protectedCacheSize)
Creates a caching variant of the supplied closure with automatic cache size adjustment and lower limit
on the cache size.
|
static <T> groovy.lang.Closure<T> |
gmemoizeAtMost(groovy.lang.Closure<T> cl,
int maxCacheSize)
Creates a caching variant of the supplied closure with upper limit on the cache size.
|
static <T> groovy.lang.Closure<T> |
gmemoizeBetween(groovy.lang.Closure<T> cl,
int protectedCacheSize,
int maxCacheSize)
Creates a caching variant of the supplied closure with automatic cache size adjustment and lower and upper limits
on the cache size.
|
static <T> java.util.Collection<T> |
grepParallel(java.util.Collection<T> collection,
java.lang.Object filter)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
rule as the filter predicate.
|
static <K,V> java.util.Map<K,V> |
grepParallel(java.util.Map<K,V> collection,
java.lang.Object filter)
Creates a Parallel Array out of the supplied map and invokes the withFilter() method using the supplied
rule as the filter predicate.
|
static java.lang.Object |
grepParallel(java.lang.Object collection,
java.lang.Object filter)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
rule as the filter predicate.
|
static <K,T> java.util.Map<K,java.util.List<T>> |
groupByParallel(java.util.Collection<T> collection,
groovy.lang.Closure<K> cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withMapping() method using the supplied
closure as the mapping predicate.
|
static <K> java.util.Map<K,java.util.List<java.lang.Object>> |
groupByParallel(java.lang.Object collection,
groovy.lang.Closure<K> cl)
Creates a Parallel Array out of the supplied collection/object and invokes the withMapping() method using the supplied
closure as the mapping predicate.
|
private static <K,T> java.util.Map<K,java.util.List<T>> |
groupByParallelPA(ParallelArray<T> pa,
groovy.lang.Closure<K> cl) |
static boolean |
isConcurrent(java.lang.Object collection)
Indicates whether the iterative methods like each() or collect() work have been altered to work concurrently.
|
static <T> java.util.concurrent.Future<T> |
leftShift(jsr166y.ForkJoinPool pool,
groovy.lang.Closure<T> task)
Submits the task for asynchronous processing returning the Future received from the executor service.
|
static java.lang.Object |
makeConcurrent(java.lang.Object collection)
Overrides the iterative methods like each(), collect() and such, so that they call their parallel variants from the GParsPoolUtil class
like eachParallel(), collectParallel() and such.
|
static java.lang.Object |
makeSequential(java.lang.Object collection)
Gives the iterative methods like each() or find() the original sequential semantics.
|
static <T> T |
maxParallel(java.util.Collection<T> collection)
Creates a Parallel Array out of the supplied collection/object and invokes its max() method using the default comparator.
|
static <T> T |
maxParallel(java.util.Collection<T> collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes its max() method using the supplied
closure as the comparator.
|
static java.lang.Object |
maxParallel(java.lang.Object collection)
Creates a Parallel Array out of the supplied collection/object and invokes its max() method using the default comparator.
|
static java.lang.Object |
maxParallel(java.lang.Object collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes its max() method using the supplied
closure as the comparator.
|
static <T> T |
minParallel(java.util.Collection<T> collection)
Creates a Parallel Array out of the supplied collection/object and invokes its min() method using the default comparator.
|
static <T> T |
minParallel(java.util.Collection<T> collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes its min() method using the supplied
closure as the comparator.
|
static java.lang.Object |
minParallel(java.lang.Object collection)
Creates a Parallel Array out of the supplied collection/object and invokes its min() method using the default comparator.
|
static java.lang.Object |
minParallel(java.lang.Object collection,
groovy.lang.Closure cl)
Creates a Parallel Array out of the supplied collection/object and invokes its min() method using the supplied
closure as the comparator.
|
private static jsr166y.ForkJoinPool |
retrievePool() |
static <T> java.util.Collection<T> |
splitParallel(java.util.Collection<T> collection,
java.lang.Object filter)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
rule as the filter predicate.
|
static java.lang.Object |
splitParallel(java.lang.Object collection,
java.lang.Object filter)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied
rule as the filter predicate.
|
static <T> T |
sumParallel(java.util.Collection<T> collection)
Creates a Parallel Array out of the supplied collection/object and summarizes its elements using the foldParallel()
method with the + operator and the reduction operation.
|
static java.lang.Object |
sumParallel(java.lang.Object collection)
Creates a Parallel Array out of the supplied collection/object and summarizes its elements using the foldParallel()
method with the + operator and the reduction operation.
|
private static final GeneralTimer timer
private static jsr166y.ForkJoinPool retrievePool()
public static <T> java.util.concurrent.Future<T> callParallel(groovy.lang.Closure<T> task)
public static <T> java.util.concurrent.Future<T> callAsync(groovy.lang.Closure<T> cl, java.lang.Object... args)
public static <T> java.util.concurrent.Future<T> callTimeoutAsync(groovy.lang.Closure<T> cl, long timeout, java.lang.Object... args)
timeout
- The timeout in milliseconds to wait before the calculation gets cancelled.public static <T> java.util.concurrent.Future<T> callTimeoutAsync(groovy.lang.Closure<T> cl, groovy.time.Duration timeout, java.lang.Object... args)
timeout
- The timeout to wait before the calculation gets cancelled.public static <T> java.util.concurrent.Future<T> leftShift(jsr166y.ForkJoinPool pool, groovy.lang.Closure<T> task)
executorService << {println 'Inside parallel task'}*
public static groovy.lang.Closure async(groovy.lang.Closure cl)
public static groovy.lang.Closure asyncFun(groovy.lang.Closure original)
public static groovy.lang.Closure asyncFun(groovy.lang.Closure original, boolean blocking)
public static groovy.lang.Closure asyncFun(groovy.lang.Closure original, FJPool pool)
public static groovy.lang.Closure asyncFun(groovy.lang.Closure original, FJPool pool, boolean blocking)
public static <T> groovy.lang.Closure<T> gmemoize(groovy.lang.Closure<T> cl)
public static <T> groovy.lang.Closure<T> gmemoizeAtMost(groovy.lang.Closure<T> cl, int maxCacheSize)
maxCacheSize
- The maximum size the cache can grow topublic static <T> groovy.lang.Closure<T> gmemoizeAtLeast(groovy.lang.Closure<T> cl, int protectedCacheSize)
public static <T> groovy.lang.Closure<T> gmemoizeBetween(groovy.lang.Closure<T> cl, int protectedCacheSize, int maxCacheSize)
private static <K,V> ParallelArray<java.util.Map.Entry<K,V>> createPA(java.util.Map<K,V> collection, jsr166y.ForkJoinPool pool)
public static java.lang.Object makeConcurrent(java.lang.Object collection)
collection
- The object to make transparentpublic static java.lang.Object makeSequential(java.lang.Object collection)
collection
- The collection to apply the change topublic static void asConcurrent(java.lang.Object collection, groovy.lang.Closure code)
collection
- The collection to enhancecode
- The closure to run with the collection enhanced.public static boolean isConcurrent(java.lang.Object collection)
public static <T> java.util.Collection<T> eachParallel(java.util.Collection<T> collection, groovy.lang.Closure cl)
GParsPool.withPool {* def result = new ConcurrentSkipListSet() [1, 2, 3, 4, 5].eachParallel {Number number -> result.add(number * 10)}* assertEquals(new HashSet([10, 20, 30, 40, 50]), result) }*Note that the result variable is synchronized to prevent race conditions between multiple threads.
public static <T> T eachParallel(T collection, groovy.lang.Closure cl)
GParsPool.withPool {* def result = new ConcurrentSkipListSet() [1, 2, 3, 4, 5].eachParallel {Number number -> result.add(number * 10)}* assertEquals(new HashSet([10, 20, 30, 40, 50]), result) }*Note that the result variable is synchronized to prevent race conditions between multiple threads.
public static <K,V> java.util.Map<K,V> eachParallel(java.util.Map<K,V> collection, groovy.lang.Closure cl)
GParsPool.withPool {* def result = new ConcurrentSkipListSet() [1, 2, 3, 4, 5].eachParallel {Number number -> result.add(number * 10)}* assertEquals(new HashSet([10, 20, 30, 40, 50]), result) }*Note that the result variable is synchronized to prevent race conditions between multiple threads.
public static <T> java.util.Collection<T> eachWithIndexParallel(java.util.Collection<T> collection, groovy.lang.Closure cl)
GParsPool.withPool {* def result = new ConcurrentSkipListSet() [1, 2, 3, 4, 5].eachWithIndexParallel {Number number, int index -> result.add(number * 10)}* assertEquals(new HashSet([10, 20, 30, 40, 50]), result) }*Note that the result variable is synchronized to prevent race conditions between multiple threads.
public static <T> T eachWithIndexParallel(T collection, groovy.lang.Closure cl)
GParsPool.withPool {* def result = new ConcurrentSkipListSet() [1, 2, 3, 4, 5].eachWithIndexParallel {Number number, int index -> result.add(number * 10)}* assertEquals(new HashSet([10, 20, 30, 40, 50]), result) }*Note that the result variable is synchronized to prevent race conditions between multiple threads.
public static <K,V> java.util.Map<K,V> eachWithIndexParallel(java.util.Map<K,V> collection, groovy.lang.Closure cl)
public static <T> java.util.Collection<T> collectParallel(java.util.Collection collection, groovy.lang.Closure<? extends T> cl)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].collectParallel {Number number -> number * 10}* assertEquals(new HashSet([10, 20, 30, 40, 50]), result) }*
public static <T> java.util.Collection<T> collectParallel(java.lang.Object collection, groovy.lang.Closure<? extends T> cl)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].collectParallel {Number number -> number * 10}* assertEquals(new HashSet([10, 20, 30, 40, 50]), result) }*
public static <T> java.util.Collection<T> collectParallel(java.util.Map collection, groovy.lang.Closure<? extends T> cl)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].collectParallel {Number number -> number * 10}* assertEquals(new HashSet([10, 20, 30, 40, 50]), result) }*
public static <T> java.util.List<T> collectManyParallel(java.util.Collection collection, groovy.lang.Closure<java.util.Collection<? extends T>> projection)
projection
closure as the transformation operation. The projection
closure should return a
(possibly empty) collection of items which are subsequently flattened to produce a new collection.
The projection
closure will be effectively invoked concurrently on the elements of the original collection.
It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access.
Alternatively a DSL can be used to simplify the code. All collections/objects within the withPool block
have a new collectManyParallel(Closure projection) method, which delegates to the GParsPoolUtil class.
Example:
GParsPool.withPool {* def squaresAndCubesOfOdds = [1, 2, 3, 4, 5].collectManyParallel { Number number -> number % 2 ? [number ** 2, number ** 3] : [] }* assert squaresAndCubesOfOdds == [1, 1, 9, 27, 25, 125] }*
public static <T> java.util.List<T> collectManyParallel(java.lang.Object collection, groovy.lang.Closure<java.util.Collection<? extends T>> projection)
projection
closure as the transformation operation. The projection
closure should return a
(possibly empty) collection of items which are subsequently flattened to produce a new collection.
The projection
closure will be effectively invoked concurrently on the elements of the original collection.
It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access.
Alternatively a DSL can be used to simplify the code. All collections/objects within the withPool block
have a new collectManyParallel(Closure projection) method, which delegates to the GParsPoolUtil class.
Example:
GParsPool.withPool {* def squaresAndCubesOfOdds = [1, 2, 3, 4, 5].collectManyParallel { Number number -> number % 2 ? [number ** 2, number ** 3] : [] }* assert squaresAndCubesOfOdds == [1, 1, 9, 27, 25, 125] }*
public static <T> java.util.List<T> collectManyParallel(java.util.Map collection, groovy.lang.Closure<java.util.Collection<? extends T>> projection)
projection
closure as the transformation operation. The projection
closure should return a
(possibly empty) collection of items which are subsequently flattened to produce a new collection.
The projection
closure will be effectively invoked concurrently on the elements of the original collection.
It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access.
Alternatively a DSL can be used to simplify the code. All collections/objects within the withPool block
have a new collectManyParallel(Closure projection) method, which delegates to the GParsPoolUtil class.
Example:
GParsPool.withPool {* def squaresAndCubesOfOdds = [1, 2, 3, 4, 5].collectManyParallel { Number number -> number % 2 ? [number ** 2, number ** 3] : [] }* assert squaresAndCubesOfOdds == [1, 1, 9, 27, 25, 125] }*
public static <T> java.util.Collection<T> findAllParallel(java.util.Collection<T> collection, groovy.lang.Closure cl)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].findAllParallel {Number number -> number > 3}* assertEquals(new HashSet([4, 5]), result) }*
public static java.util.Collection<java.lang.Object> findAllParallel(java.lang.Object collection, groovy.lang.Closure cl)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].findAllParallel {Number number -> number > 3}* assertEquals(new HashSet([4, 5]), result) }*
public static <K,V> java.util.Map<K,V> findAllParallel(java.util.Map<K,V> collection, groovy.lang.Closure cl)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].findAllParallel {Number number -> number > 3}* assertEquals(new HashSet([4, 5]), result)
}*
public static <T> T findParallel(java.util.Collection<T> collection, groovy.lang.Closure cl)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].findParallel {Number number -> number > 3}* assert (result in [4, 5]) }*
public static java.lang.Object findParallel(java.lang.Object collection, groovy.lang.Closure cl)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].findParallel {Number number -> number > 3}* assert (result in [4, 5]) }*
public static <K,V> java.util.Map.Entry<K,V> findParallel(java.util.Map<K,V> collection, groovy.lang.Closure cl)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].findParallel {Number number -> number > 3}* assert (result in [4, 5]) }*
public static <T> T findAnyParallel(java.util.Collection<T> collection, groovy.lang.Closure cl)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].findParallel {Number number -> number > 3}* assert (result in [4, 5]) }*
public static java.lang.Object findAnyParallel(java.lang.Object collection, groovy.lang.Closure cl)
public static <K,V> java.util.Map.Entry<K,V> findAnyParallel(java.util.Map<K,V> collection, groovy.lang.Closure cl)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].findAnyParallel {Number number -> number > 3}* assert (result in [4, 5]) }*
public static <T> java.util.Collection<T> grepParallel(java.util.Collection<T> collection, java.lang.Object filter)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].grepParallel(4..6) assertEquals(new HashSet([4, 5]), result) }*
public static java.lang.Object grepParallel(java.lang.Object collection, java.lang.Object filter)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].grepParallel(4..6) assertEquals(new HashSet([4, 5]), result) }*
public static <K,V> java.util.Map<K,V> grepParallel(java.util.Map<K,V> collection, java.lang.Object filter)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].grepParallel(4..6) assertEquals(new HashSet([4, 5]), result) }*
public static <T> java.util.Collection<T> splitParallel(java.util.Collection<T> collection, java.lang.Object filter)
public static java.lang.Object splitParallel(java.lang.Object collection, java.lang.Object filter)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].splitParallel(4..6) assert [3, 4, 5] as Set == result[0] as Set assert [1, 2] as Set == result[1] as Set }*
public static int countParallel(java.util.Collection collection, java.lang.Object filter)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].countParallel(4) assertEquals(1, result) }*
public static int countParallel(java.lang.Object collection, java.lang.Object filter)
GParsPool.withPool {* def result = [1, 2, 3, 4, 5].countParallel(4) assertEquals(1, result) }*
public static int countParallel(java.util.Collection collection, groovy.lang.Closure filter)
GParsPool.withPool {* def isOdd = { it % 2 }* def result = [1, 2, 3, 4, 5].countParallel(isOdd) assert result == 3 }*
public static int countParallel(java.lang.Object collection, groovy.lang.Closure filter)
GParsPool.withPool {* def isEven = { it % 2 == 0 }* def result = [1, 2, 3, 4, 5].countParallel(isEven) assert result == 2 }*
public static boolean anyParallel(java.util.Collection collection, groovy.lang.Closure cl)
GParsPool.withPool {* assert [1, 2, 3, 4, 5].anyParallel {Number number -> number > 3}* assert ![1, 2, 3].anyParallel {Number number -> number > 3}*}*
public static boolean anyParallel(java.lang.Object collection, groovy.lang.Closure cl)
GParsPool.withPool {* assert [1, 2, 3, 4, 5].anyParallel {Number number -> number > 3}* assert ![1, 2, 3].anyParallel {Number number -> number > 3}*}*
public static boolean anyParallel(java.util.Map collection, groovy.lang.Closure cl)
GParsPool.withPool {* assert [1, 2, 3, 4, 5].anyParallel {Number number -> number > 3}* assert ![1, 2, 3].anyParallel {Number number -> number > 3}*}*
public static boolean everyParallel(java.util.Collection collection, groovy.lang.Closure cl)
GParsPool.withPool(5) {* assert ![1, 2, 3, 4, 5].everyParallel {Number number -> number > 3}* assert [1, 2, 3].everyParallel() {Number number -> number <= 3}*}*
public static boolean everyParallel(java.lang.Object collection, groovy.lang.Closure cl)
GParsPool.withPool(5) {* assert ![1, 2, 3, 4, 5].everyParallel {Number number -> number > 3}* assert [1, 2, 3].everyParallel() {Number number -> number <= 3}*}*
public static boolean everyParallel(java.util.Map collection, groovy.lang.Closure cl)
GParsPool.withPool(5) {* assert ![1, 2, 3, 4, 5].everyParallel {Number number -> number > 3}* assert [1, 2, 3].everyParallel() {Number number -> number <= 3}*}*
public static <K,T> java.util.Map<K,java.util.List<T>> groupByParallel(java.util.Collection<T> collection, groovy.lang.Closure<K> cl)
GParsPool.withPool {* assert ([1, 2, 3, 4, 5].groupByParallel {Number number -> number % 2}).size() == 2 }*
public static <K> java.util.Map<K,java.util.List<java.lang.Object>> groupByParallel(java.lang.Object collection, groovy.lang.Closure<K> cl)
GParsPool.withPool {* assert ([1, 2, 3, 4, 5].groupByParallel {Number number -> number % 2}).size() == 2 }*
private static <K,T> java.util.Map<K,java.util.List<T>> groupByParallelPA(ParallelArray<T> pa, groovy.lang.Closure<K> cl)
public static <T> T minParallel(java.util.Collection<T> collection, groovy.lang.Closure cl)
cl
- A one or two-argument closurepublic static java.lang.Object minParallel(java.lang.Object collection, groovy.lang.Closure cl)
cl
- A one or two-argument closurepublic static <T> T minParallel(java.util.Collection<T> collection)
public static java.lang.Object minParallel(java.lang.Object collection)
public static <T> T maxParallel(java.util.Collection<T> collection, groovy.lang.Closure cl)
cl
- A one or two-argument closurepublic static java.lang.Object maxParallel(java.lang.Object collection, groovy.lang.Closure cl)
cl
- A one or two-argument closurepublic static <T> T maxParallel(java.util.Collection<T> collection)
public static java.lang.Object maxParallel(java.lang.Object collection)
public static <T> T sumParallel(java.util.Collection<T> collection)
public static java.lang.Object sumParallel(java.lang.Object collection)
public static <T> T foldParallel(java.util.Collection<T> collection, groovy.lang.Closure cl)
public static java.lang.Object foldParallel(java.lang.Object collection, groovy.lang.Closure cl)
public static <T> T foldParallel(java.util.Collection<T> collection, T seed, groovy.lang.Closure cl)
seed
- A seed value to initialize the operationpublic static java.lang.Object foldParallel(java.lang.Object collection, java.lang.Object seed, groovy.lang.Closure cl)
seed
- A seed value to initialize the operationpublic static <T> groovyx.gpars.pa.PAWrapper<T> getParallel(java.util.Collection<T> collection)
public static groovyx.gpars.pa.PAWrapper getParallel(java.lang.Object collection)
public static <T> ParallelArray<T> getParallelArray(java.util.Collection<T> collection)
public static ParallelArray getParallelArray(java.lang.Object collection)