Class ParallelIterate
- java.lang.Object
-
- org.eclipse.collections.impl.parallel.ParallelIterate
-
public final class ParallelIterate extends java.lang.ObjectThe ParallelIterate class contains several parallel algorithms that work with Collections. All the higher level parallel algorithms depend on the basic parallel algorithm namedforEach. The forEach algorithm employs a batching fork and join approach.All Collections that are not either a
RandomAccessorListare first converted to a Java array usingIterate.toArray(Iterable), and then run with one of theParallelArrayIterate.forEachmethods.- See Also:
ParallelArrayIterate
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classParallelIterate.SumByBigDecimalCombiner<T,V>private static classParallelIterate.SumByBigDecimalProcedure<T,V>private static classParallelIterate.SumByBigIntegerCombiner<T,V>private static classParallelIterate.SumByBigIntegerProcedure<T,V>private static classParallelIterate.SumByDoubleCombiner<T,V>private static classParallelIterate.SumByDoubleProcedure<T,V>private static classParallelIterate.SumByFloatCombiner<T,V>private static classParallelIterate.SumByFloatProcedure<T,V>private static classParallelIterate.SumByIntCombiner<T,V>private static classParallelIterate.SumByIntProcedure<T,V>private static classParallelIterate.SumByLongCombiner<T,V>private static classParallelIterate.SumByLongProcedure<T,V>
-
Field Summary
Fields Modifier and Type Field Description (package private) static intAVAILABLE_PROCESSORS(package private) static intDEFAULT_MIN_FORK_SIZE(package private) static intDEFAULT_PARALLEL_TASK_COUNT(package private) static java.util.concurrent.ExecutorServiceEXECUTOR_SERVICE(package private) static intTASK_RATIO
-
Constructor Summary
Constructors Modifier Constructor Description privateParallelIterate()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,K,V>
MutableMap<K,V>aggregateBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator)static <T,K,V>
MutableMap<K,V>aggregateBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator, int batchSize)static <T,K,V>
MutableMap<K,V>aggregateBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator, int batchSize, java.util.concurrent.Executor executor)static <T,K,V,R extends MutableMapIterable<K,V>>
RaggregateBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator, R mutableMap)static <T,K,V,R extends MutableMapIterable<K,V>>
RaggregateBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator, R mutableMap, int batchSize)static <T,K,V,R extends MutableMapIterable<K,V>>
RaggregateBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator, R mutableMap, int batchSize, java.util.concurrent.Executor executor)static <T,K,V>
MutableMap<K,V>aggregateInPlaceBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator)static <T,K,V>
MutableMap<K,V>aggregateInPlaceBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator, int batchSize)static <T,K,V>
MutableMap<K,V>aggregateInPlaceBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator, int batchSize, java.util.concurrent.Executor executor)static <T,K,V,R extends MutableMapIterable<K,V>>
RaggregateInPlaceBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator, R mutableMap)static <T,K,V,R extends MutableMapIterable<K,V>>
RaggregateInPlaceBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator, R mutableMap, int batchSize)static <T,K,V,R extends MutableMapIterable<K,V>>
RaggregateInPlaceBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator, R mutableMap, int batchSize, java.util.concurrent.Executor executor)private static intcalculateTaskCount(int size, int batchSize)private static <T> intcalculateTaskCount(java.lang.Iterable<T> iterable, int batchSize)private static <T> intcalculateTaskCount(BatchIterable<T> batchIterable, int batchSize)static <T,V>
java.util.Collection<V>collect(java.lang.Iterable<T> iterable, Function<? super T,V> function)Same effect asIterate.collect(Iterable, Function), but executed in parallel batches.static <T,V>
java.util.Collection<V>collect(java.lang.Iterable<T> iterable, Function<? super T,V> function, boolean allowReorderedResult)Same effect asIterate.collect(Iterable, Function), but executed in parallel batches, and with potentially reordered result.static <T,V,R extends java.util.Collection<V>>
Rcollect(java.lang.Iterable<T> iterable, Function<? super T,V> function, R target, boolean allowReorderedResult)Same effect asIterate.collect(Iterable, Function), but executed in parallel batches, and writing output into the specified collection.static <T,V,R extends java.util.Collection<V>>
Rcollect(java.lang.Iterable<T> iterable, 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, Predicate<? super T> predicate, Function<? super T,V> function)Same effect asIterate.collectIf(Iterable, Predicate, Function), but executed in parallel batches.static <T,V>
java.util.Collection<V>collectIf(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, Function<? super T,V> function, boolean allowReorderedResult)Same effect asIterate.collectIf(Iterable, Predicate, Function), but executed in parallel batches, and with potentially reordered results.static <T,V,R extends java.util.Collection<V>>
RcollectIf(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, Function<? super T,V> function, R target, boolean allowReorderedResult)Same effect asIterate.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>>
RcollectIf(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, Function<? super T,V> function, R target, int batchSize, java.util.concurrent.Executor executor, boolean allowReorderedResult)static <T> intcount(java.lang.Iterable<T> iterable, Predicate<? super T> predicate)Same effect asIterate.count(Iterable, Predicate), but executed in parallel batches.static <T> intcount(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, int batchSize, java.util.concurrent.Executor executor)Same effect asIterate.count(Iterable, Predicate), but executed in parallel batches.static <T,V>
java.util.Collection<V>flatCollect(java.lang.Iterable<T> iterable, Function<? super T,java.util.Collection<V>> function)static <T,V>
java.util.Collection<V>flatCollect(java.lang.Iterable<T> iterable, Function<? super T,java.util.Collection<V>> function, boolean allowReorderedResult)static <T,V,R extends java.util.Collection<V>>
RflatCollect(java.lang.Iterable<T> iterable, Function<? super T,java.util.Collection<V>> function, R target, boolean allowReorderedResult)static <T,V,R extends java.util.Collection<V>>
RflatCollect(java.lang.Iterable<T> iterable, Function<? super T,java.util.Collection<V>> function, R target, int batchSize, java.util.concurrent.Executor executor, boolean allowReorderedResult)static <T,BT extends Procedure<? super T>>
voidforEach(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 Procedure<? super T>>
voidforEach(java.lang.Iterable<T> iterable, BT procedure, int minForkSize, int taskCount, java.util.concurrent.Executor executor)static <T,BT extends Procedure<? super T>>
voidforEach(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> voidforEach(java.lang.Iterable<T> iterable, Procedure<? super T> procedure)Iterate over the collection specified in parallel batches using default runtime parameter values.static <T> voidforEach(java.lang.Iterable<T> iterable, Procedure<? super T> procedure, int batchSize)Iterate over the collection specified in parallel batches using default runtime parameter values.static <T> voidforEach(java.lang.Iterable<T> iterable, Procedure<? super T> procedure, int batchSize, java.util.concurrent.Executor executor)static <T,BT extends Procedure<? super T>>
voidforEach(java.lang.Iterable<T> iterable, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner)static <T,BT extends Procedure<? super T>>
voidforEach(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 Procedure<? super T>>
voidforEach(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 Procedure<? super T>>
voidforEach(java.lang.Iterable<T> iterable, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount, java.util.concurrent.Executor executor)static <T,BT extends Procedure<? super T>>
voidforEach(java.lang.Iterable<T> iterable, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int batchSize, java.util.concurrent.Executor executor)static <T,BT extends Procedure<? super T>>
voidforEach(java.lang.Iterable<T> iterable, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, java.util.concurrent.Executor executor)static <T,BT extends Procedure<? super T>>
voidforEachInBatchWithExecutor(BatchIterable<T> set, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount, java.util.concurrent.Executor executor)static <T,BT extends Procedure<? super T>>
voidforEachInListOnExecutor(java.util.List<T> list, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount, java.util.concurrent.Executor executor)static <T,BT extends ObjectIntProcedure<? super T>>
voidforEachWithIndex(java.lang.Iterable<T> iterable, BT procedure, int minForkSize, int taskCount)Iterate over the collection specified in parallel batches.static <T,BT extends ObjectIntProcedure<? super T>>
voidforEachWithIndex(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> voidforEachWithIndex(java.lang.Iterable<T> iterable, ObjectIntProcedure<? super T> objectIntProcedure)Iterate over the collection specified, in parallel batches using default runtime parameter values.static <T,BT extends ObjectIntProcedure<? super T>>
voidforEachWithIndex(java.lang.Iterable<T> iterable, ObjectIntProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount)static <T,BT extends ObjectIntProcedure<? super T>>
voidforEachWithIndex(java.lang.Iterable<T> iterable, ObjectIntProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount, java.util.concurrent.Executor executor)static <T,BT extends ObjectIntProcedure<? super T>>
voidforEachWithIndex(java.lang.Iterable<T> iterable, ObjectIntProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, java.util.concurrent.Executor executor)static <T,BT extends ObjectIntProcedure<? super T>>
voidforEachWithIndexInListOnExecutor(java.util.List<T> list, ObjectIntProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount, java.util.concurrent.Executor executor)static intgetDefaultMaxThreadPoolSize()static intgetDefaultTaskCount()static intgetTaskRatio()static <K,V>
MutableMultimap<K,V>groupBy(java.lang.Iterable<V> iterable, Function<? super V,? extends K> function)Same effect asIterate.groupBy(Iterable, Function), but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.static <K,V>
MutableMultimap<K,V>groupBy(java.lang.Iterable<V> iterable, Function<? super V,? extends K> function, int batchSize)Same effect asIterate.groupBy(Iterable, Function), but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.static <K,V>
MutableMultimap<K,V>groupBy(java.lang.Iterable<V> iterable, Function<? super V,? extends K> function, int batchSize, java.util.concurrent.Executor executor)Same effect asIterate.groupBy(Iterable, Function), but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.static <K,V,R extends MutableMultimap<K,V>>
MutableMultimap<K,V>groupBy(java.lang.Iterable<V> iterable, Function<? super V,? extends K> function, R concurrentMultimap)Same effect asIterate.groupBy(Iterable, Function), but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.static <K,V,R extends MutableMultimap<K,V>>
MutableMultimap<K,V>groupBy(java.lang.Iterable<V> iterable, Function<? super V,? extends K> function, R concurrentMultimap, int batchSize)Same effect asIterate.groupBy(Iterable, Function), but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.static <K,V,R extends MutableMultimap<K,V>>
MutableMultimap<K,V>groupBy(java.lang.Iterable<V> iterable, Function<? super V,? extends K> function, R concurrentMultimap, int batchSize, java.util.concurrent.Executor executor)Same effect asIterate.groupBy(Iterable, Function), but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.(package private) static booleanisExecutorShutdown()static java.util.concurrent.ExecutorServicenewPooledExecutor(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.ExecutorServicenewPooledExecutor(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, Predicate<? super T> predicate)Same effect asIterate.reject(Iterable, Predicate), but executed in parallel batches.static <T> java.util.Collection<T>reject(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, boolean allowReorderedResult)Same effect asIterate.reject(Iterable, Predicate), but executed in parallel batches, and with a potentially reordered result.static <T,R extends java.util.Collection<T>>
Rreject(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, R target, boolean allowReorderedResult)Same effect asIterate.reject(Iterable, Predicate), but executed in parallel batches, and writing output into the specified collection.static <T,R extends java.util.Collection<T>>
Rreject(java.lang.Iterable<T> iterable, 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, Predicate<? super T> predicate)Same effect asIterate.select(Iterable, Predicate), but executed in parallel batches.static <T> java.util.Collection<T>select(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, boolean allowReorderedResult)Same effect asIterate.select(Iterable, Predicate), but executed in parallel batches, and with a potentially reordered result.static <T,R extends java.util.Collection<T>>
Rselect(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, R target, boolean allowReorderedResult)Same effect asIterate.select(Iterable, Predicate), but executed in parallel batches, and writing output into the specified collection.static <T,R extends java.util.Collection<T>>
Rselect(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, R target, int batchSize, java.util.concurrent.Executor executor, boolean allowReorderedResult)Same effect asIterate.select(Iterable, Predicate), but executed in parallel batches, and writing output into the specified collection.(package private) static voidshutdownExecutor()static <V,T>
MutableMap<V,java.math.BigDecimal>sumByBigDecimal(java.lang.Iterable<T> iterable, Function<? super T,? extends V> groupBy, Function<? super T,java.math.BigDecimal> function)static <V,T>
MutableMap<V,java.math.BigInteger>sumByBigInteger(java.lang.Iterable<T> iterable, Function<? super T,? extends V> groupBy, Function<? super T,java.math.BigInteger> function)static <T,V>
ObjectDoubleMap<V>sumByDouble(java.lang.Iterable<T> iterable, Function<? super T,? extends V> groupBy, DoubleFunction<? super T> function)static <T,V>
ObjectDoubleMap<V>sumByFloat(java.lang.Iterable<T> iterable, Function<? super T,? extends V> groupBy, FloatFunction<? super T> function)static <T,V>
ObjectLongMap<V>sumByInt(java.lang.Iterable<T> iterable, Function<? super T,? extends V> groupBy, IntFunction<? super T> function)static <T,V>
ObjectLongMap<V>sumByLong(java.lang.Iterable<T> iterable, Function<? super T,? extends V> groupBy, LongFunction<? super T> function)
-
-
-
Field Detail
-
DEFAULT_MIN_FORK_SIZE
static final int DEFAULT_MIN_FORK_SIZE
- See Also:
- Constant Field Values
-
AVAILABLE_PROCESSORS
static final int AVAILABLE_PROCESSORS
-
TASK_RATIO
static final int TASK_RATIO
- See Also:
- Constant Field Values
-
DEFAULT_PARALLEL_TASK_COUNT
static final int DEFAULT_PARALLEL_TASK_COUNT
-
EXECUTOR_SERVICE
static final java.util.concurrent.ExecutorService EXECUTOR_SERVICE
-
-
Method Detail
-
isExecutorShutdown
static boolean isExecutorShutdown()
-
shutdownExecutor
static void shutdownExecutor()
-
forEachWithIndex
public static <T> void forEachWithIndex(java.lang.Iterable<T> iterable, ObjectIntProcedure<? super T> objectIntProcedure)Iterate over the collection specified, in parallel batches using default runtime parameter values. TheObjectIntProcedureused must be stateless, or use concurrent aware objects if they are to be shared.e.g.
Map<Integer, Object> chm = new ConcurrentHashMap<Integer, Object>(); ParallelIterate.forEachWithIndex(collection, (each, index) -> chm.put(index, each));
-
forEachWithIndex
public static <T,BT extends ObjectIntProcedure<? super T>> void 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. The ObjectIntProcedure used must be stateless, or use concurrent aware objects if they are to be shared. The code is executed against the specified executor.e.g. Map<Integer, Object> chm = new ConcurrentHashMap<Integer, Object>(); ParallelIterate.forEachWithIndex(collection, (each, index) -> chm.put(index, each), executor);
- Parameters:
executor- Use this executor for all execution.
-
forEachWithIndex
public static <T,BT extends ObjectIntProcedure<? super T>> void forEachWithIndex(java.lang.Iterable<T> iterable, BT procedure, int minForkSize, int taskCount)
Iterate over the collection specified in parallel batches. The ObjectIntProcedure used must be stateless, or use concurrent aware objects if they are to be shared. The specified minimum fork size and task count are used instead of the default values.- Parameters:
minForkSize- Only run in parallel if input collection is longer than this.taskCount- How many parallel tasks to submit to the executor.- See Also:
forEachWithIndex(Iterable, ObjectIntProcedure)
-
forEachWithIndex
public static <T,BT extends ObjectIntProcedure<? super T>> void forEachWithIndex(java.lang.Iterable<T> iterable, ObjectIntProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, java.util.concurrent.Executor executor)
-
forEachWithIndex
public static <T,BT extends ObjectIntProcedure<? super T>> void forEachWithIndex(java.lang.Iterable<T> iterable, ObjectIntProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount)
-
forEachWithIndex
public static <T,BT extends 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)
-
forEachWithIndexInListOnExecutor
public static <T,BT extends 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)
-
forEach
public static <T> void forEach(java.lang.Iterable<T> iterable, Procedure<? super T> procedure)Iterate over the collection specified in parallel batches using default runtime parameter values. TheProcedureused must be stateless, or use concurrent aware objects if they are to be shared.e.g.
Map<Object, Boolean> chm = new ConcurrentHashMap<Object, Boolean>(); ParallelIterate.forEach(collection, each -> chm.put(each, Boolean.TRUE));
-
forEach
public static <T> void forEach(java.lang.Iterable<T> iterable, Procedure<? super T> procedure, int batchSize)Iterate over the collection specified in parallel batches using default runtime parameter values. TheProcedureused must be stateless, or use concurrent aware objects if they are to be shared.e.g.
Map<Object, Boolean> chm = new ConcurrentHashMap<Object, Boolean>(); ParallelIterate.forEachBatchSize(collection, each -> chm.put(each, Boolean.TRUE), 100);
-
forEach
public static <T> void forEach(java.lang.Iterable<T> iterable, Procedure<? super T> procedure, int batchSize, java.util.concurrent.Executor executor)
-
forEach
public static <T,BT extends Procedure<? super T>> void 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. TheProcedureused must be stateless, or use concurrent aware objects if they are to be shared.- Parameters:
executor- Use this executor for all execution.- See Also:
forEach(Iterable, Procedure)
-
forEach
public static <T,BT extends Procedure<? super T>> void 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. TheProcedureused must be stateless, or use concurrent aware objects if they are to be shared.- Parameters:
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?- See Also:
forEach(Iterable, Procedure)
-
forEach
public static <T,BT extends Procedure<? super T>> void forEach(java.lang.Iterable<T> iterable, BT procedure, int minForkSize, int taskCount, java.util.concurrent.Executor executor)
-
forEach
public static <T,BT extends Procedure<? super T>> void forEach(java.lang.Iterable<T> iterable, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, java.util.concurrent.Executor executor)
-
forEach
public static <T,BT extends Procedure<? super T>> void forEach(java.lang.Iterable<T> iterable, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner)
-
forEach
public static <T,BT extends Procedure<? super T>> void 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. The ProcedureFactory can create stateful closures that will be collected and combined using the specified Combiner.e.g. The ParallelIterate.select() implementation CollectionCombiner<T, SelectProcedure<T>> combiner = CollectionCombiner.forSelect(collection); ParallelIterate.forEach(collection, new SelectProcedureFactory<T>(predicate, taskSize), combiner, 1000);
-
forEach
public static <T,BT extends Procedure<? super T>> void forEach(java.lang.Iterable<T> iterable, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int batchSize, java.util.concurrent.Executor executor)
-
forEach
public static <T,BT extends Procedure<? super T>> void 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. The ProcedureFactory can create stateful closures that will be collected and combined using the specified Combiner.e.g. The ParallelIterate.select() implementation int 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);
-
forEach
public static <T,BT extends 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)
-
forEachInListOnExecutor
public static <T,BT extends 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)
-
forEachInBatchWithExecutor
public static <T,BT extends Procedure<? super T>> void forEachInBatchWithExecutor(BatchIterable<T> set, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount, java.util.concurrent.Executor executor)
-
select
public static <T> java.util.Collection<T> select(java.lang.Iterable<T> iterable, Predicate<? super T> predicate)Same effect asIterate.select(Iterable, Predicate), but executed in parallel batches.- Returns:
- The selected elements. The Collection will be of the same type as the input (List or Set) and will be in the same order as the input (if it is an ordered collection).
- See Also:
select(Iterable, Predicate, boolean)
-
select
public static <T> java.util.Collection<T> select(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, boolean allowReorderedResult)Same effect asIterate.select(Iterable, Predicate), but executed in parallel batches, and with a potentially reordered result.- Parameters:
allowReorderedResult- If the result can be in a different order. Allowing reordering may yield faster execution.- Returns:
- The selected elements. The Collection will be of the same type (List or Set) as the input.
-
select
public static <T,R extends java.util.Collection<T>> R select(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, R target, boolean allowReorderedResult)Same effect asIterate.select(Iterable, Predicate), but executed in parallel batches, and writing output into the specified collection.- Parameters:
target- Where to write the output.allowReorderedResult- If the result can be in a different order. Allowing reordering may yield faster execution.- Returns:
- The 'target' collection, with the selected elements added.
-
select
public static <T,R extends java.util.Collection<T>> R select(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, R target, int batchSize, java.util.concurrent.Executor executor, boolean allowReorderedResult)Same effect asIterate.select(Iterable, Predicate), but executed in parallel batches, and writing output into the specified collection.- Parameters:
target- Where to write the output.allowReorderedResult- If the result can be in a different order. Allowing reordering may yield faster execution.- Returns:
- The 'target' collection, with the selected elements added.
-
calculateTaskCount
private static <T> int calculateTaskCount(java.lang.Iterable<T> iterable, int batchSize)
-
calculateTaskCount
private static <T> int calculateTaskCount(BatchIterable<T> batchIterable, int batchSize)
-
calculateTaskCount
private static int calculateTaskCount(int size, int batchSize)
-
reject
public static <T> java.util.Collection<T> reject(java.lang.Iterable<T> iterable, Predicate<? super T> predicate)Same effect asIterate.reject(Iterable, Predicate), but executed in parallel batches.- Returns:
- The rejected elements. The Collection will be of the same type as the input (List or Set) and will be in the same order as the input (if it is an ordered collection).
- See Also:
reject(Iterable, Predicate, boolean)
-
reject
public static <T> java.util.Collection<T> reject(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, boolean allowReorderedResult)Same effect asIterate.reject(Iterable, Predicate), but executed in parallel batches, and with a potentially reordered result.- Parameters:
allowReorderedResult- If the result can be in a different order. Allowing reordering may yield faster execution.- Returns:
- The rejected elements. The Collection will be of the same type (List or Set) as the input.
-
reject
public static <T,R extends java.util.Collection<T>> R reject(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, R target, boolean allowReorderedResult)Same effect asIterate.reject(Iterable, Predicate), but executed in parallel batches, and writing output into the specified collection.- Parameters:
target- Where to write the output.allowReorderedResult- If the result can be in a different order. Allowing reordering may yield faster execution.- Returns:
- The 'target' collection, with the rejected elements added.
-
reject
public static <T,R extends java.util.Collection<T>> R reject(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, R target, int batchSize, java.util.concurrent.Executor executor, boolean allowReorderedResult)
-
count
public static <T> int count(java.lang.Iterable<T> iterable, Predicate<? super T> predicate)Same effect asIterate.count(Iterable, Predicate), but executed in parallel batches.- Returns:
- The number of elements which satisfy the predicate.
-
count
public static <T> int count(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, int batchSize, java.util.concurrent.Executor executor)Same effect asIterate.count(Iterable, Predicate), but executed in parallel batches.- Returns:
- The number of elements which satisfy the predicate.
-
collect
public static <T,V> java.util.Collection<V> collect(java.lang.Iterable<T> iterable, Function<? super T,V> function)Same effect asIterate.collect(Iterable, Function), but executed in parallel batches.- Returns:
- The collected elements. The Collection will be of the same type as the input (List or Set) and will be in the same order as the input (if it is an ordered collection).
- See Also:
collect(Iterable, Function, boolean)
-
collect
public static <T,V> java.util.Collection<V> collect(java.lang.Iterable<T> iterable, Function<? super T,V> function, boolean allowReorderedResult)Same effect asIterate.collect(Iterable, Function), but executed in parallel batches, and with potentially reordered result.- Parameters:
allowReorderedResult- If the result can be in a different order. Allowing reordering may yield faster execution.- Returns:
- The collected elements. The Collection will be of the same type (List or Set) as the input.
-
collect
public static <T,V,R extends java.util.Collection<V>> R collect(java.lang.Iterable<T> iterable, Function<? super T,V> function, R target, boolean allowReorderedResult)Same effect asIterate.collect(Iterable, Function), but executed in parallel batches, and writing output into the specified collection.- Parameters:
target- Where to write the output.allowReorderedResult- If the result can be in a different order. Allowing reordering may yield faster execution.- Returns:
- The 'target' collection, with the collected elements added.
-
collect
public static <T,V,R extends java.util.Collection<V>> R collect(java.lang.Iterable<T> iterable, Function<? super T,V> function, R target, int batchSize, java.util.concurrent.Executor executor, boolean allowReorderedResult)
-
flatCollect
public static <T,V> java.util.Collection<V> flatCollect(java.lang.Iterable<T> iterable, Function<? super T,java.util.Collection<V>> function)
-
flatCollect
public static <T,V> java.util.Collection<V> flatCollect(java.lang.Iterable<T> iterable, Function<? super T,java.util.Collection<V>> function, boolean allowReorderedResult)
-
flatCollect
public static <T,V,R extends java.util.Collection<V>> R flatCollect(java.lang.Iterable<T> iterable, Function<? super T,java.util.Collection<V>> function, R target, boolean allowReorderedResult)
-
flatCollect
public static <T,V,R extends java.util.Collection<V>> R flatCollect(java.lang.Iterable<T> iterable, Function<? super T,java.util.Collection<V>> function, R target, int batchSize, java.util.concurrent.Executor executor, boolean allowReorderedResult)
-
collectIf
public static <T,V> java.util.Collection<V> collectIf(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, Function<? super T,V> function)Same effect asIterate.collectIf(Iterable, Predicate, Function), but executed in parallel batches.- Returns:
- The collected elements. The Collection will be of the same type as the input (List or Set) and will be in the same order as the input (if it is an ordered collection).
- See Also:
collectIf(Iterable, Predicate, Function, boolean)
-
collectIf
public static <T,V> java.util.Collection<V> collectIf(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, Function<? super T,V> function, boolean allowReorderedResult)Same effect asIterate.collectIf(Iterable, Predicate, Function), but executed in parallel batches, and with potentially reordered results.- Parameters:
allowReorderedResult- If the result can be in a different order. Allowing reordering may yield faster execution.- Returns:
- The collected elements. The Collection will be of the same type as the input (List or Set)
-
collectIf
public static <T,V,R extends java.util.Collection<V>> R collectIf(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, Function<? super T,V> function, R target, boolean allowReorderedResult)Same effect asIterate.collectIf(Iterable, Predicate, Function), but executed in parallel batches, and writing output into the specified collection.- Parameters:
target- Where to write the output.allowReorderedResult- If the result can be in a different order. Allowing reordering may yield faster execution.- Returns:
- The 'target' collection, with the collected elements added.
-
collectIf
public static <T,V,R extends java.util.Collection<V>> R collectIf(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, Function<? super T,V> function, R target, int batchSize, java.util.concurrent.Executor executor, boolean allowReorderedResult)
-
groupBy
public static <K,V> MutableMultimap<K,V> groupBy(java.lang.Iterable<V> iterable, Function<? super V,? extends K> function)
Same effect asIterate.groupBy(Iterable, Function), but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.
-
aggregateBy
public static <T,K,V> MutableMap<K,V> aggregateBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator)
-
aggregateBy
public static <T,K,V,R extends MutableMapIterable<K,V>> R aggregateBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator, R mutableMap)
-
aggregateBy
public static <T,K,V> MutableMap<K,V> aggregateBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator, int batchSize)
-
aggregateBy
public static <T,K,V,R extends MutableMapIterable<K,V>> R aggregateBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator, R mutableMap, int batchSize)
-
aggregateBy
public static <T,K,V> MutableMap<K,V> aggregateBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator, int batchSize, java.util.concurrent.Executor executor)
-
aggregateBy
public static <T,K,V,R extends MutableMapIterable<K,V>> R aggregateBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator, R mutableMap, int batchSize, java.util.concurrent.Executor executor)
-
aggregateInPlaceBy
public static <T,K,V> MutableMap<K,V> aggregateInPlaceBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator)
-
aggregateInPlaceBy
public static <T,K,V,R extends MutableMapIterable<K,V>> R aggregateInPlaceBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator, R mutableMap)
-
aggregateInPlaceBy
public static <T,K,V> MutableMap<K,V> aggregateInPlaceBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator, int batchSize)
-
aggregateInPlaceBy
public static <T,K,V,R extends MutableMapIterable<K,V>> R aggregateInPlaceBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator, R mutableMap, int batchSize)
-
aggregateInPlaceBy
public static <T,K,V> MutableMap<K,V> aggregateInPlaceBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator, int batchSize, java.util.concurrent.Executor executor)
-
aggregateInPlaceBy
public static <T,K,V,R extends MutableMapIterable<K,V>> R aggregateInPlaceBy(java.lang.Iterable<T> iterable, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator, R mutableMap, int batchSize, java.util.concurrent.Executor executor)
-
groupBy
public static <K,V,R extends MutableMultimap<K,V>> MutableMultimap<K,V> groupBy(java.lang.Iterable<V> iterable, Function<? super V,? extends K> function, R concurrentMultimap)
Same effect asIterate.groupBy(Iterable, Function), but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.
-
groupBy
public static <K,V,R extends MutableMultimap<K,V>> MutableMultimap<K,V> groupBy(java.lang.Iterable<V> iterable, Function<? super V,? extends K> function, R concurrentMultimap, int batchSize)
Same effect asIterate.groupBy(Iterable, Function), but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.
-
groupBy
public static <K,V> MutableMultimap<K,V> groupBy(java.lang.Iterable<V> iterable, Function<? super V,? extends K> function, int batchSize)
Same effect asIterate.groupBy(Iterable, Function), but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.
-
groupBy
public static <K,V> MutableMultimap<K,V> groupBy(java.lang.Iterable<V> iterable, Function<? super V,? extends K> function, int batchSize, java.util.concurrent.Executor executor)
Same effect asIterate.groupBy(Iterable, Function), but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.
-
groupBy
public static <K,V,R extends MutableMultimap<K,V>> MutableMultimap<K,V> groupBy(java.lang.Iterable<V> iterable, Function<? super V,? extends K> function, R concurrentMultimap, int batchSize, java.util.concurrent.Executor executor)
Same effect asIterate.groupBy(Iterable, Function), but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.
-
sumByDouble
public static <T,V> ObjectDoubleMap<V> sumByDouble(java.lang.Iterable<T> iterable, Function<? super T,? extends V> groupBy, DoubleFunction<? super T> function)
-
sumByFloat
public static <T,V> ObjectDoubleMap<V> sumByFloat(java.lang.Iterable<T> iterable, Function<? super T,? extends V> groupBy, FloatFunction<? super T> function)
-
sumByLong
public static <T,V> ObjectLongMap<V> sumByLong(java.lang.Iterable<T> iterable, Function<? super T,? extends V> groupBy, LongFunction<? super T> function)
-
sumByInt
public static <T,V> ObjectLongMap<V> sumByInt(java.lang.Iterable<T> iterable, Function<? super T,? extends V> groupBy, IntFunction<? super T> function)
-
sumByBigDecimal
public static <V,T> MutableMap<V,java.math.BigDecimal> sumByBigDecimal(java.lang.Iterable<T> iterable, Function<? super T,? extends V> groupBy, Function<? super T,java.math.BigDecimal> function)
- Since:
- 6.0
-
sumByBigInteger
public static <V,T> MutableMap<V,java.math.BigInteger> sumByBigInteger(java.lang.Iterable<T> iterable, Function<? super T,? extends V> groupBy, Function<? super T,java.math.BigInteger> function)
- Since:
- 6.0
-
newPooledExecutor
public 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. The same poolName may be used more than once resulting in multiple pools with the same name.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.
-
newPooledExecutor
public 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. The same poolName may be used more than once resulting in multiple pools with the same name.
-
getDefaultTaskCount
public static int getDefaultTaskCount()
-
getDefaultMaxThreadPoolSize
public static int getDefaultMaxThreadPoolSize()
-
getTaskRatio
public static int getTaskRatio()
-
-