public final class ParallelIterate
extends java.lang.Object
forEach. The forEach algorithm employs
a batching fork and join approach.
All Collections that are not either a RandomAccess or List are first converted to a Java array
using Iterate.toArray(Iterable), and then run with one of the ParallelArrayIterate.forEach methods.
ParallelArrayIterate| Modifier and Type | Method and Description |
|---|---|
static <T,K,V> com.gs.collections.api.map.MutableMap<K,V> |
aggregateBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator) |
static <T,K,V> com.gs.collections.api.map.MutableMap<K,V> |
aggregateBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator,
int batchSize) |
static <T,K,V> com.gs.collections.api.map.MutableMap<K,V> |
aggregateBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator,
int batchSize,
java.util.concurrent.Executor executor) |
static <T,K,V,R extends com.gs.collections.api.map.MutableMap<K,V>> |
aggregateBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator,
R mutableMap) |
static <T,K,V,R extends com.gs.collections.api.map.MutableMap<K,V>> |
aggregateBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator,
R mutableMap,
int batchSize) |
static <T,K,V,R extends com.gs.collections.api.map.MutableMap<K,V>> |
aggregateBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator,
R mutableMap,
int batchSize,
java.util.concurrent.Executor executor) |
static <T,K,V> com.gs.collections.api.map.MutableMap<K,V> |
aggregateInPlaceBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator) |
static <T,K,V> com.gs.collections.api.map.MutableMap<K,V> |
aggregateInPlaceBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator,
int batchSize) |
static <T,K,V> com.gs.collections.api.map.MutableMap<K,V> |
aggregateInPlaceBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator,
int batchSize,
java.util.concurrent.Executor executor) |
static <T,K,V,R extends com.gs.collections.api.map.MutableMap<K,V>> |
aggregateInPlaceBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator,
R mutableMap) |
static <T,K,V,R extends com.gs.collections.api.map.MutableMap<K,V>> |
aggregateInPlaceBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator,
R mutableMap,
int batchSize) |
static <T,K,V,R extends com.gs.collections.api.map.MutableMap<K,V>> |
aggregateInPlaceBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator,
R mutableMap,
int batchSize,
java.util.concurrent.Executor executor) |
static <T,V> java.util.Collection<V> |
collect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,V> function)
Same effect as
Iterate.collect(Iterable, Function),
but executed in parallel batches. |
static <T,V> java.util.Collection<V> |
collect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,V> function,
boolean allowReorderedResult)
Same effect as
Iterate.collect(Iterable, Function), but executed in parallel batches,
and with potentially reordered result. |
static <T,V,R extends java.util.Collection<V>> |
collect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,V> function,
R target,
boolean allowReorderedResult)
Same effect as
Iterate.collect(Iterable, Function), but executed in parallel batches,
and writing output into the specified collection. |
static <T,V,R extends java.util.Collection<V>> |
collect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,V> function,
R target,
int batchSize,
java.util.concurrent.Executor executor,
boolean allowReorderedResult) |
static <T,V> java.util.Collection<V> |
collectIf(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
com.gs.collections.api.block.function.Function<? super T,V> function)
Same effect as
Iterate.collectIf(Iterable, Predicate, Function),
but executed in parallel batches. |
static <T,V> java.util.Collection<V> |
collectIf(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
com.gs.collections.api.block.function.Function<? super T,V> function,
boolean allowReorderedResult)
Same effect as
Iterate.collectIf(Iterable, Predicate, Function),
but executed in parallel batches, and with potentially reordered results. |
static <T,V,R extends java.util.Collection<V>> |
collectIf(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
com.gs.collections.api.block.function.Function<? super T,V> function,
R target,
boolean allowReorderedResult)
Same effect as
Iterate.collectIf(Iterable, Predicate, Function),
but executed in parallel batches, and writing output into the specified collection. |
static <T,V,R extends java.util.Collection<V>> |
collectIf(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
com.gs.collections.api.block.function.Function<? super T,V> function,
R target,
int batchSize,
java.util.concurrent.Executor executor,
boolean allowReorderedResult) |
static <T> int |
count(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Same effect as
Iterate.count(Iterable, Predicate), but executed in parallel batches. |
static <T> int |
count(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
int batchSize,
java.util.concurrent.Executor executor)
Same effect as
Iterate.count(Iterable, Predicate), but executed in parallel batches. |
static <T,V> java.util.Collection<V> |
flatCollect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,java.util.Collection<V>> function) |
static <T,V> java.util.Collection<V> |
flatCollect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,java.util.Collection<V>> function,
boolean allowReorderedResult) |
static <T,V,R extends java.util.Collection<V>> |
flatCollect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,java.util.Collection<V>> function,
R target,
boolean allowReorderedResult) |
static <T,V,R extends java.util.Collection<V>> |
flatCollect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,java.util.Collection<V>> function,
R target,
int batchSize,
java.util.concurrent.Executor executor,
boolean allowReorderedResult) |
static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> |
forEach(java.lang.Iterable<T> iterable,
BT procedure,
java.util.concurrent.Executor executor)
Iterate over the collection specified in parallel batches using default runtime parameter values
and the specified executor.
|
static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> |
forEach(java.lang.Iterable<T> iterable,
BT procedure,
int minForkSize,
int taskCount)
Iterate over the collection specified in parallel batches using the specified minimum fork and task count sizes.
|
static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> |
forEach(java.lang.Iterable<T> iterable,
BT procedure,
int minForkSize,
int taskCount,
java.util.concurrent.Executor executor) |
static <T> void |
forEach(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.procedure.Procedure<? super T> procedure)
Iterate over the collection specified in parallel batches using default runtime parameter values.
|
static <T> void |
forEach(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.procedure.Procedure<? super T> procedure,
int batchSize)
Iterate over the collection specified in parallel batches using default runtime parameter values.
|
static <T> void |
forEach(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.procedure.Procedure<? super T> procedure,
int batchSize,
java.util.concurrent.Executor executor) |
static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> |
forEach(java.lang.Iterable<T> iterable,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner) |
static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> |
forEach(java.lang.Iterable<T> iterable,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
java.util.concurrent.Executor executor) |
static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> |
forEach(java.lang.Iterable<T> iterable,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int batchSize)
Iterate over the collection specified in parallel batches using the default values for the task size.
|
static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> |
forEach(java.lang.Iterable<T> iterable,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int batchSize,
java.util.concurrent.Executor executor) |
static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> |
forEach(java.lang.Iterable<T> iterable,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int minForkSize,
int taskCount)
Iterate over the collection specified in parallel batches using the default values for the task size.
|
static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> |
forEach(java.lang.Iterable<T> iterable,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int minForkSize,
int taskCount,
java.util.concurrent.Executor executor) |
static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> |
forEachInBatchWithExecutor(BatchIterable<T> set,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int minForkSize,
int taskCount,
java.util.concurrent.Executor executor) |
static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> |
forEachInListOnExecutor(java.util.List<T> list,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int minForkSize,
int taskCount,
java.util.concurrent.Executor executor) |
static <T,BT extends com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T>> |
forEachWithIndex(java.lang.Iterable<T> iterable,
BT procedure,
java.util.concurrent.Executor executor)
Iterate over the collection specified in parallel batches using the default runtime parameters.
|
static <T,BT extends com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T>> |
forEachWithIndex(java.lang.Iterable<T> iterable,
BT procedure,
int minForkSize,
int taskCount)
Iterate over the collection specified in parallel batches.
|
static <T> void |
forEachWithIndex(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T> objectIntProcedure)
Iterate over the collection specified, in parallel batches using default runtime parameter values.
|
static <T,BT extends com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T>> |
forEachWithIndex(java.lang.Iterable<T> iterable,
ObjectIntProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
java.util.concurrent.Executor executor) |
static <T,BT extends com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T>> |
forEachWithIndex(java.lang.Iterable<T> iterable,
ObjectIntProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int minForkSize,
int taskCount) |
static <T,BT extends com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T>> |
forEachWithIndex(java.lang.Iterable<T> iterable,
ObjectIntProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int minForkSize,
int taskCount,
java.util.concurrent.Executor executor) |
static <T,BT extends com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T>> |
forEachWithIndexInListOnExecutor(java.util.List<T> list,
ObjectIntProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int minForkSize,
int taskCount,
java.util.concurrent.Executor executor) |
static int |
getDefaultMaxThreadPoolSize() |
static int |
getDefaultTaskCount() |
static int |
getTaskRatio() |
static <K,V> com.gs.collections.api.multimap.MutableMultimap<K,V> |
groupBy(java.lang.Iterable<V> iterable,
com.gs.collections.api.block.function.Function<? super V,? extends K> function)
Same effect as
Iterate.groupBy(Iterable, Function),
but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap. |
static <K,V> com.gs.collections.api.multimap.MutableMultimap<K,V> |
groupBy(java.lang.Iterable<V> iterable,
com.gs.collections.api.block.function.Function<? super V,? extends K> function,
int batchSize)
Same effect as
Iterate.groupBy(Iterable, Function),
but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap. |
static <K,V> com.gs.collections.api.multimap.MutableMultimap<K,V> |
groupBy(java.lang.Iterable<V> iterable,
com.gs.collections.api.block.function.Function<? super V,? extends K> function,
int batchSize,
java.util.concurrent.Executor executor)
Same effect as
Iterate.groupBy(Iterable, Function),
but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap. |
static <K,V,R extends com.gs.collections.api.multimap.MutableMultimap<K,V>> |
groupBy(java.lang.Iterable<V> iterable,
com.gs.collections.api.block.function.Function<? super V,? extends K> function,
R concurrentMultimap)
Same effect as
Iterate.groupBy(Iterable, Function),
but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap. |
static <K,V,R extends com.gs.collections.api.multimap.MutableMultimap<K,V>> |
groupBy(java.lang.Iterable<V> iterable,
com.gs.collections.api.block.function.Function<? super V,? extends K> function,
R concurrentMultimap,
int batchSize)
Same effect as
Iterate.groupBy(Iterable, Function),
but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap. |
static <K,V,R extends com.gs.collections.api.multimap.MutableMultimap<K,V>> |
groupBy(java.lang.Iterable<V> iterable,
com.gs.collections.api.block.function.Function<? super V,? extends K> function,
R concurrentMultimap,
int batchSize,
java.util.concurrent.Executor executor)
Same effect as
Iterate.groupBy(Iterable, Function),
but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap. |
static java.util.concurrent.ExecutorService |
newPooledExecutor(int newPoolSize,
java.lang.String poolName,
boolean useDaemonThreads)
Returns a brand new ExecutorService using the specified poolName with the specified maximum thread pool size.
|
static java.util.concurrent.ExecutorService |
newPooledExecutor(java.lang.String poolName,
boolean useDaemonThreads)
Returns a brand new ExecutorService using the specified poolName and uses the optional property named
to set the maximum thread pool size.
|
static <T> java.util.Collection<T> |
reject(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Same effect as
Iterate.reject(Iterable, Predicate), but executed in parallel batches. |
static <T> java.util.Collection<T> |
reject(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
boolean allowReorderedResult)
Same effect as
Iterate.reject(Iterable, Predicate), but executed in parallel batches,
and with a potentially reordered result. |
static <T,R extends java.util.Collection<T>> |
reject(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
R target,
boolean allowReorderedResult)
Same effect as
Iterate.reject(Iterable, Predicate), but executed in parallel batches,
and writing output into the specified collection. |
static <T,R extends java.util.Collection<T>> |
reject(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
R target,
int batchSize,
java.util.concurrent.Executor executor,
boolean allowReorderedResult) |
static <T> java.util.Collection<T> |
select(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Same effect as
Iterate.select(Iterable, Predicate), but executed in parallel batches. |
static <T> java.util.Collection<T> |
select(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
boolean allowReorderedResult)
Same effect as
Iterate.select(Iterable, Predicate), but executed in parallel batches,
and with a potentially reordered result. |
static <T,R extends java.util.Collection<T>> |
select(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
R target,
boolean allowReorderedResult)
Same effect as
Iterate.select(Iterable, Predicate), but executed in parallel batches,
and writing output into the specified collection. |
static <T,R extends java.util.Collection<T>> |
select(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
R target,
int batchSize,
java.util.concurrent.Executor executor,
boolean allowReorderedResult)
Same effect as
Iterate.select(Iterable, Predicate), but executed in parallel batches,
and writing output into the specified collection. |
static <V,T> com.gs.collections.api.map.MutableMap<V,java.math.BigDecimal> |
sumByBigDecimal(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<T,V> groupBy,
com.gs.collections.api.block.function.Function<? super T,java.math.BigDecimal> function) |
static <V,T> com.gs.collections.api.map.MutableMap<V,java.math.BigInteger> |
sumByBigInteger(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<T,V> groupBy,
com.gs.collections.api.block.function.Function<? super T,java.math.BigInteger> function) |
static <T,V> com.gs.collections.api.map.primitive.ObjectDoubleMap<V> |
sumByDouble(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<T,V> groupBy,
com.gs.collections.api.block.function.primitive.DoubleFunction<? super T> function) |
static <T,V> com.gs.collections.api.map.primitive.ObjectDoubleMap<V> |
sumByFloat(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<T,V> groupBy,
com.gs.collections.api.block.function.primitive.FloatFunction<? super T> function) |
static <T,V> com.gs.collections.api.map.primitive.ObjectLongMap<V> |
sumByInt(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<T,V> groupBy,
com.gs.collections.api.block.function.primitive.IntFunction<? super T> function) |
static <T,V> com.gs.collections.api.map.primitive.ObjectLongMap<V> |
sumByLong(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<T,V> groupBy,
com.gs.collections.api.block.function.primitive.LongFunction<? super T> function) |
public static <T> void forEachWithIndex(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T> objectIntProcedure)
ObjectIntProcedure used must be stateless, or use concurrent aware objects if they are to be shared.
e.g.
final Map<Integer, Object> chm = new ConcurrentHashMap<Integer, Object>();
ParallelIterate.forEachWithIndex(collection, new ObjectIntProcedure()
{
public void value(Object object, int index)
{
chm.put(index, object);
}
});
public static <T,BT extends com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T>> void forEachWithIndex(java.lang.Iterable<T> iterable,
BT procedure,
java.util.concurrent.Executor executor)
e.g.
final Map<Integer, Object> chm = new ConcurrentHashMap<Integer, Object>();
ParallelIterate.forEachWithIndex(collection, new ObjectIntProcedure()
{
public void value(Object object, int index)
{
chm.put(index, object);
}
}, executor);
executor - Use this executor for all execution.public static <T,BT extends com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T>> void forEachWithIndex(java.lang.Iterable<T> iterable,
BT procedure,
int minForkSize,
int taskCount)
minForkSize - Only run in parallel if input collection is longer than this.taskCount - How many parallel tasks to submit to the executor.forEachWithIndex(Iterable, ObjectIntProcedure)public static <T,BT extends com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T>> void forEachWithIndex(java.lang.Iterable<T> iterable,
ObjectIntProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
java.util.concurrent.Executor executor)
public static <T,BT extends com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T>> void forEachWithIndex(java.lang.Iterable<T> iterable,
ObjectIntProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int minForkSize,
int taskCount)
public static <T,BT extends com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T>> void forEachWithIndex(java.lang.Iterable<T> iterable,
ObjectIntProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int minForkSize,
int taskCount,
java.util.concurrent.Executor executor)
public static <T,BT extends com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T>> void forEachWithIndexInListOnExecutor(java.util.List<T> list,
ObjectIntProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int minForkSize,
int taskCount,
java.util.concurrent.Executor executor)
public static <T> void forEach(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.procedure.Procedure<? super T> procedure)
Procedure used must be stateless, or use concurrent aware objects if they are to be shared.
e.g.
final Map<Object, Boolean> chm = new ConcurrentHashMap<Object, Boolean>();
ParallelIterate.forEach(collection, new Procedure()
{
public void value(Object object)
{
chm.put(object, Boolean.TRUE);
}
});
public static <T> void forEach(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.procedure.Procedure<? super T> procedure,
int batchSize)
Procedure used must be stateless, or use concurrent aware objects if they are to be shared.
e.g.
final Map<Object, Boolean> chm = new ConcurrentHashMap<Object, Boolean>();
ParallelIterate.forEachBatchSize(collection, new Procedure()
{
public void value(Object object)
{
chm.put(object, Boolean.TRUE);
}
}, 100);
public static <T> void forEach(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.procedure.Procedure<? super T> procedure,
int batchSize,
java.util.concurrent.Executor executor)
public static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> void forEach(java.lang.Iterable<T> iterable,
BT procedure,
java.util.concurrent.Executor executor)
Procedure used must be stateless, or use concurrent aware objects if they are to be shared.executor - Use this executor for all execution.forEach(Iterable, Procedure)public static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> void forEach(java.lang.Iterable<T> iterable,
BT procedure,
int minForkSize,
int taskCount)
Procedure used must be stateless, or use concurrent aware objects if they are to be shared.minForkSize - Only run in parallel if input collection is longer than this.taskCount - How many parallel tasks to submit to the executor.
TODO: How does the taskCount relate to the number of threads in the executor?forEach(Iterable, Procedure)public static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> void forEach(java.lang.Iterable<T> iterable,
BT procedure,
int minForkSize,
int taskCount,
java.util.concurrent.Executor executor)
public static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> void forEach(java.lang.Iterable<T> iterable,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
java.util.concurrent.Executor executor)
public static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> void forEach(java.lang.Iterable<T> iterable,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner)
public static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> void forEach(java.lang.Iterable<T> iterable,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int batchSize)
e.g. The ParallelIterate.select() implementation
CollectionCombiner<T, SelectProcedure<T>> combiner = CollectionCombiner.forSelect(collection);ParallelIterate.forEach(collection,new SelectProcedureFactory<T>(predicate, taskSize), combiner, 1000);
public static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> void forEach(java.lang.Iterable<T> iterable,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int batchSize,
java.util.concurrent.Executor executor)
public static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> void forEach(java.lang.Iterable<T> iterable,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int minForkSize,
int taskCount)
e.g. The ParallelIterate.select() implementationint taskCount = Math.max(DEFAULT_PARALLEL_TASK_COUNT, collection.size() / DEFAULT_MIN_FORK_SIZE); final int taskSize = collection.size() / taskCount / 2;
CollectionCombiner<T, SelectProcedure<T>> combiner = CollectionCombiner.forSelect(collection);ParallelIterate.forEach(collection,new SelectProcedureFactory<T>(predicate, taskSize), combiner, DEFAULT_MIN_FORK_SIZE, taskCount);
public static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> void forEach(java.lang.Iterable<T> iterable,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int minForkSize,
int taskCount,
java.util.concurrent.Executor executor)
public static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> void forEachInListOnExecutor(java.util.List<T> list,
ProcedureFactory<BT> procedureFactory,
Combiner<BT> combiner,
int minForkSize,
int taskCount,
java.util.concurrent.Executor executor)
public static <T,BT extends com.gs.collections.api.block.procedure.Procedure<? super T>> void forEachInBatchWithExecutor(BatchIterable<T> set, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount, java.util.concurrent.Executor executor)
public static <T> java.util.Collection<T> select(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Iterate.select(Iterable, Predicate), but executed in parallel batches.select(Iterable, Predicate, boolean)public static <T> java.util.Collection<T> select(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
boolean allowReorderedResult)
Iterate.select(Iterable, Predicate), but executed in parallel batches,
and with a potentially reordered result.allowReorderedResult - If the result can be in a different order.
Allowing reordering may yield faster execution.public static <T,R extends java.util.Collection<T>> R select(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
R target,
boolean allowReorderedResult)
Iterate.select(Iterable, Predicate), but executed in parallel batches,
and writing output into the specified collection.target - Where to write the output.allowReorderedResult - If the result can be in a different order.
Allowing reordering may yield faster execution.public static <T,R extends java.util.Collection<T>> R select(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
R target,
int batchSize,
java.util.concurrent.Executor executor,
boolean allowReorderedResult)
Iterate.select(Iterable, Predicate), but executed in parallel batches,
and writing output into the specified collection.target - Where to write the output.allowReorderedResult - If the result can be in a different order.
Allowing reordering may yield faster execution.public static <T> java.util.Collection<T> reject(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Iterate.reject(Iterable, Predicate), but executed in parallel batches.reject(Iterable, Predicate, boolean)public static <T> java.util.Collection<T> reject(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
boolean allowReorderedResult)
Iterate.reject(Iterable, Predicate), but executed in parallel batches,
and with a potentially reordered result.allowReorderedResult - If the result can be in a different order.
Allowing reordering may yield faster execution.public static <T,R extends java.util.Collection<T>> R reject(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
R target,
boolean allowReorderedResult)
Iterate.reject(Iterable, Predicate), but executed in parallel batches,
and writing output into the specified collection.target - Where to write the output.allowReorderedResult - If the result can be in a different order.
Allowing reordering may yield faster execution.public static <T,R extends java.util.Collection<T>> R reject(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
R target,
int batchSize,
java.util.concurrent.Executor executor,
boolean allowReorderedResult)
public static <T> int count(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Iterate.count(Iterable, Predicate), but executed in parallel batches.public static <T> int count(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
int batchSize,
java.util.concurrent.Executor executor)
Iterate.count(Iterable, Predicate), but executed in parallel batches.public static <T,V> java.util.Collection<V> collect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,V> function)
Iterate.collect(Iterable, Function),
but executed in parallel batches.collect(Iterable, Function, boolean)public static <T,V> java.util.Collection<V> collect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,V> function,
boolean allowReorderedResult)
Iterate.collect(Iterable, Function), but executed in parallel batches,
and with potentially reordered result.allowReorderedResult - If the result can be in a different order.
Allowing reordering may yield faster execution.public static <T,V,R extends java.util.Collection<V>> R collect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,V> function,
R target,
boolean allowReorderedResult)
Iterate.collect(Iterable, Function), but executed in parallel batches,
and writing output into the specified collection.target - Where to write the output.allowReorderedResult - If the result can be in a different order.
Allowing reordering may yield faster execution.public static <T,V,R extends java.util.Collection<V>> R collect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,V> function,
R target,
int batchSize,
java.util.concurrent.Executor executor,
boolean allowReorderedResult)
public static <T,V> java.util.Collection<V> flatCollect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,java.util.Collection<V>> function)
public static <T,V> java.util.Collection<V> flatCollect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,java.util.Collection<V>> function,
boolean allowReorderedResult)
public static <T,V,R extends java.util.Collection<V>> R flatCollect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,java.util.Collection<V>> function,
R target,
boolean allowReorderedResult)
public static <T,V,R extends java.util.Collection<V>> R flatCollect(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,java.util.Collection<V>> function,
R target,
int batchSize,
java.util.concurrent.Executor executor,
boolean allowReorderedResult)
public static <T,V> java.util.Collection<V> collectIf(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
com.gs.collections.api.block.function.Function<? super T,V> function)
Iterate.collectIf(Iterable, Predicate, Function),
but executed in parallel batches.collectIf(Iterable, Predicate, Function, boolean)public static <T,V> java.util.Collection<V> collectIf(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
com.gs.collections.api.block.function.Function<? super T,V> function,
boolean allowReorderedResult)
Iterate.collectIf(Iterable, Predicate, Function),
but executed in parallel batches, and with potentially reordered results.allowReorderedResult - If the result can be in a different order.
Allowing reordering may yield faster execution.public static <T,V,R extends java.util.Collection<V>> R collectIf(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
com.gs.collections.api.block.function.Function<? super T,V> function,
R target,
boolean allowReorderedResult)
Iterate.collectIf(Iterable, Predicate, Function),
but executed in parallel batches, and writing output into the specified collection.target - Where to write the output.allowReorderedResult - If the result can be in a different order.
Allowing reordering may yield faster execution.public static <T,V,R extends java.util.Collection<V>> R collectIf(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
com.gs.collections.api.block.function.Function<? super T,V> function,
R target,
int batchSize,
java.util.concurrent.Executor executor,
boolean allowReorderedResult)
public static <K,V> com.gs.collections.api.multimap.MutableMultimap<K,V> groupBy(java.lang.Iterable<V> iterable,
com.gs.collections.api.block.function.Function<? super V,? extends K> function)
Iterate.groupBy(Iterable, Function),
but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.public static <T,K,V> com.gs.collections.api.map.MutableMap<K,V> aggregateBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator)
public static <T,K,V,R extends com.gs.collections.api.map.MutableMap<K,V>> R aggregateBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator,
R mutableMap)
public static <T,K,V> com.gs.collections.api.map.MutableMap<K,V> aggregateBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator,
int batchSize)
public static <T,K,V,R extends com.gs.collections.api.map.MutableMap<K,V>> R aggregateBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator,
R mutableMap,
int batchSize)
public static <T,K,V> com.gs.collections.api.map.MutableMap<K,V> aggregateBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator,
int batchSize,
java.util.concurrent.Executor executor)
public static <T,K,V,R extends com.gs.collections.api.map.MutableMap<K,V>> R aggregateBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator,
R mutableMap,
int batchSize,
java.util.concurrent.Executor executor)
public static <T,K,V> com.gs.collections.api.map.MutableMap<K,V> aggregateInPlaceBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator)
public static <T,K,V,R extends com.gs.collections.api.map.MutableMap<K,V>> R aggregateInPlaceBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator,
R mutableMap)
public static <T,K,V> com.gs.collections.api.map.MutableMap<K,V> aggregateInPlaceBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator,
int batchSize)
public static <T,K,V,R extends com.gs.collections.api.map.MutableMap<K,V>> R aggregateInPlaceBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator,
R mutableMap,
int batchSize)
public static <T,K,V> com.gs.collections.api.map.MutableMap<K,V> aggregateInPlaceBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator,
int batchSize,
java.util.concurrent.Executor executor)
public static <T,K,V,R extends com.gs.collections.api.map.MutableMap<K,V>> R aggregateInPlaceBy(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator,
R mutableMap,
int batchSize,
java.util.concurrent.Executor executor)
public static <K,V,R extends com.gs.collections.api.multimap.MutableMultimap<K,V>> com.gs.collections.api.multimap.MutableMultimap<K,V> groupBy(java.lang.Iterable<V> iterable,
com.gs.collections.api.block.function.Function<? super V,? extends K> function,
R concurrentMultimap)
Iterate.groupBy(Iterable, Function),
but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.public static <K,V,R extends com.gs.collections.api.multimap.MutableMultimap<K,V>> com.gs.collections.api.multimap.MutableMultimap<K,V> groupBy(java.lang.Iterable<V> iterable,
com.gs.collections.api.block.function.Function<? super V,? extends K> function,
R concurrentMultimap,
int batchSize)
Iterate.groupBy(Iterable, Function),
but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.public static <K,V> com.gs.collections.api.multimap.MutableMultimap<K,V> groupBy(java.lang.Iterable<V> iterable,
com.gs.collections.api.block.function.Function<? super V,? extends K> function,
int batchSize)
Iterate.groupBy(Iterable, Function),
but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.public static <K,V> com.gs.collections.api.multimap.MutableMultimap<K,V> groupBy(java.lang.Iterable<V> iterable,
com.gs.collections.api.block.function.Function<? super V,? extends K> function,
int batchSize,
java.util.concurrent.Executor executor)
Iterate.groupBy(Iterable, Function),
but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.public static <K,V,R extends com.gs.collections.api.multimap.MutableMultimap<K,V>> com.gs.collections.api.multimap.MutableMultimap<K,V> groupBy(java.lang.Iterable<V> iterable,
com.gs.collections.api.block.function.Function<? super V,? extends K> function,
R concurrentMultimap,
int batchSize,
java.util.concurrent.Executor executor)
Iterate.groupBy(Iterable, Function),
but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.public static <T,V> com.gs.collections.api.map.primitive.ObjectDoubleMap<V> sumByDouble(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<T,V> groupBy,
com.gs.collections.api.block.function.primitive.DoubleFunction<? super T> function)
public static <T,V> com.gs.collections.api.map.primitive.ObjectDoubleMap<V> sumByFloat(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<T,V> groupBy,
com.gs.collections.api.block.function.primitive.FloatFunction<? super T> function)
public static <T,V> com.gs.collections.api.map.primitive.ObjectLongMap<V> sumByLong(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<T,V> groupBy,
com.gs.collections.api.block.function.primitive.LongFunction<? super T> function)
public static <T,V> com.gs.collections.api.map.primitive.ObjectLongMap<V> sumByInt(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<T,V> groupBy,
com.gs.collections.api.block.function.primitive.IntFunction<? super T> function)
public static <V,T> com.gs.collections.api.map.MutableMap<V,java.math.BigDecimal> sumByBigDecimal(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<T,V> groupBy,
com.gs.collections.api.block.function.Function<? super T,java.math.BigDecimal> function)
public static <V,T> com.gs.collections.api.map.MutableMap<V,java.math.BigInteger> sumByBigInteger(java.lang.Iterable<T> iterable,
com.gs.collections.api.block.function.Function<T,V> groupBy,
com.gs.collections.api.block.function.Function<? super T,java.math.BigInteger> function)
public static java.util.concurrent.ExecutorService newPooledExecutor(int newPoolSize,
java.lang.String poolName,
boolean useDaemonThreads)
The pool will be initialised with newPoolSize threads. If that number of threads are in use and another thread is requested, the pool will reject execution and the submitting thread will execute the task.
public static java.util.concurrent.ExecutorService newPooledExecutor(java.lang.String poolName,
boolean useDaemonThreads)
public static int getDefaultTaskCount()
public static int getDefaultMaxThreadPoolSize()
public static int getTaskRatio()