Class FJIterate


  • public final class FJIterate
    extends java.lang.Object
    The FJIterate class contains several parallel algorithms that work with Collections and make use of Java's fork-join framework. All the higher level parallel algorithms depend on the basic parallel algorithm named 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 FJIterate.forEach methods.

    See Also:
    ParallelIterate
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private FJIterate()  
    • 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.ForkJoinPool executor)  
      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)  
      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)  
      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.ForkJoinPool 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.ForkJoinPool executor)  
      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)  
      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)  
      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.ForkJoinPool executor)  
      private static int calculateTaskCount​(int size, int batchSize)  
      private static <T> int calculateTaskCount​(java.lang.Iterable<T> iterable, int batchSize)  
      private static <T> int calculateTaskCount​(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 as Iterate.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 as Iterate.collect(Iterable, Function), but executed in parallel batches, and with potentially reordered result.
      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 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>>
      R
      collect​(java.lang.Iterable<T> iterable, Function<? super T,​V> function, R target, int batchSize, java.util.concurrent.ForkJoinPool 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 as Iterate.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 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>>
      R
      collectIf​(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, 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>>
      R
      collectIf​(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, Function<? super T,​V> function, R target, int batchSize, java.util.concurrent.ForkJoinPool executor, boolean allowReorderedResult)  
      static <T> int count​(java.lang.Iterable<T> iterable, 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, Predicate<? super T> predicate, int batchSize, java.util.concurrent.ForkJoinPool executor)
      Same effect as Iterate.count(Iterable, Predicate), but executed in parallel batches.
      (package private) static boolean executedInsideOfForEach()  
      static <T,​V>
      java.util.Collection<V>
      flatCollect​(java.lang.Iterable<T> iterable, Function<? super T,​? extends java.lang.Iterable<V>> function)  
      static <T,​V>
      java.util.Collection<V>
      flatCollect​(java.lang.Iterable<T> iterable, Function<? super T,​? extends java.lang.Iterable<V>> function, boolean allowReorderedResult)  
      static <T,​V,​R extends java.util.Collection<V>>
      R
      flatCollect​(java.lang.Iterable<T> iterable, Function<? super T,​? extends java.lang.Iterable<V>> function, R target, boolean allowReorderedResult)  
      static <T,​V,​R extends java.util.Collection<V>>
      R
      flatCollect​(java.lang.Iterable<T> iterable, Function<? super T,​? extends java.lang.Iterable<V>> function, R target, int batchSize, java.util.concurrent.ForkJoinPool executor, boolean allowReorderedResult)  
      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.
      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.
      static <T> void forEach​(java.lang.Iterable<T> iterable, Procedure<? super T> procedure, int batchSize, java.util.concurrent.ForkJoinPool executor)  
      static <T,​PT extends Procedure<? super T>>
      void
      forEach​(java.lang.Iterable<T> iterable, ProcedureFactory<PT> procedureFactory, Combiner<PT> combiner)  
      static <T,​PT extends Procedure<? super T>>
      void
      forEach​(java.lang.Iterable<T> iterable, ProcedureFactory<PT> procedureFactory, Combiner<PT> combiner, int batchSize)
      Iterate over the collection specified in parallel batches using the default values for the task size.
      static <T,​PT extends Procedure<? super T>>
      void
      forEach​(java.lang.Iterable<T> iterable, ProcedureFactory<PT> procedureFactory, Combiner<PT> combiner, int minForkSize, int taskCount)
      Iterate over the collection specified in parallel batches using the default values for the task size.
      static <T,​PT extends Procedure<? super T>>
      void
      forEach​(java.lang.Iterable<T> iterable, ProcedureFactory<PT> procedureFactory, Combiner<PT> combiner, int minForkSize, int taskCount, java.util.concurrent.ForkJoinPool executor)  
      static <T,​PT extends Procedure<? super T>>
      void
      forEach​(java.lang.Iterable<T> iterable, ProcedureFactory<PT> blockFactory, Combiner<PT> combiner, int batchSize, java.util.concurrent.ForkJoinPool executor)  
      static <T,​PT extends Procedure<? super T>>
      void
      forEach​(java.lang.Iterable<T> iterable, ProcedureFactory<PT> procedureFactory, Combiner<PT> combiner, java.util.concurrent.ForkJoinPool executor)  
      static <T,​PT extends Procedure<? super T>>
      void
      forEach​(java.lang.Iterable<T> iterable, PT procedure, int minForkSize, int taskCount)
      Iterate over the collection specified in parallel batches using the specified minimum fork and task count sizes.
      static <T,​PT extends Procedure<? super T>>
      void
      forEach​(java.lang.Iterable<T> iterable, PT procedure, int minForkSize, int taskCount, java.util.concurrent.ForkJoinPool executor)  
      static <T,​PT extends Procedure<? super T>>
      void
      forEach​(java.lang.Iterable<T> iterable, PT procedure, java.util.concurrent.ForkJoinPool executor)
      Iterate over the collection specified in parallel batches using default runtime parameter values and the specified executor.
      static <T,​PT extends Procedure<? super T>>
      void
      forEachInBatchWithExecutor​(BatchIterable<T> batchIterable, ProcedureFactory<PT> procedureFactory, Combiner<PT> combiner, int minForkSize, int taskCount, java.util.concurrent.ForkJoinPool executor)  
      static <T,​PT extends Procedure<? super T>>
      void
      forEachInListOnExecutor​(java.util.List<T> list, ProcedureFactory<PT> procedureFactory, Combiner<PT> combiner, int minForkSize, int taskCount, java.util.concurrent.ForkJoinPool executor)  
      static <T> void forEachWithIndex​(java.lang.Iterable<T> iterable, ObjectIntProcedure<? super T> procedure)
      Iterate over the collection specified, in parallel batches using default runtime parameter values.
      static <T,​PT extends ObjectIntProcedure<? super T>>
      void
      forEachWithIndex​(java.lang.Iterable<T> iterable, ObjectIntProcedureFactory<PT> procedureFactory, Combiner<PT> combiner, int minForkSize, int taskCount)  
      static <T,​PT extends ObjectIntProcedure<? super T>>
      void
      forEachWithIndex​(java.lang.Iterable<T> iterable, ObjectIntProcedureFactory<PT> procedureFactory, Combiner<PT> combiner, int minForkSize, int taskCount, java.util.concurrent.ForkJoinPool executor)  
      static <T,​PT extends ObjectIntProcedure<? super T>>
      void
      forEachWithIndex​(java.lang.Iterable<T> iterable, ObjectIntProcedureFactory<PT> procedureFactory, Combiner<PT> combiner, java.util.concurrent.ForkJoinPool executor)  
      static <T,​PT extends ObjectIntProcedure<? super T>>
      void
      forEachWithIndex​(java.lang.Iterable<T> iterable, PT procedure, int minForkSize, int taskCount)
      Iterate over the collection specified in parallel batches.
      static <T,​PT extends ObjectIntProcedure<? super T>>
      void
      forEachWithIndex​(java.lang.Iterable<T> iterable, PT procedure, java.util.concurrent.ForkJoinPool executor)
      Iterate over the collection specified in parallel batches using the default runtime parameters.
      static <T,​PT extends ObjectIntProcedure<? super T>>
      void
      forEachWithIndexInListOnExecutor​(java.util.List<T> list, ObjectIntProcedureFactory<PT> procedureFactory, Combiner<PT> combiner, int minForkSize, int taskCount, java.util.concurrent.ForkJoinPool executor)  
      static <K,​V>
      MutableMultimap<K,​V>
      groupBy​(java.lang.Iterable<V> iterable, 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>
      MutableMultimap<K,​V>
      groupBy​(java.lang.Iterable<V> iterable, 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>
      MutableMultimap<K,​V>
      groupBy​(java.lang.Iterable<V> iterable, Function<? super V,​? extends K> function, int batchSize, java.util.concurrent.ForkJoinPool executor)
      Same effect as Iterate.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 as Iterate.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 as Iterate.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.ForkJoinPool executor)
      Same effect as Iterate.groupBy(Iterable, Function), but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.
      static <T> java.util.Collection<T> reject​(java.lang.Iterable<T> iterable, 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, 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>>
      R
      reject​(java.lang.Iterable<T> iterable, 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>>
      R
      reject​(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, R target, int batchSize, java.util.concurrent.ForkJoinPool executor, boolean allowReorderedResult)  
      static <T> java.util.Collection<T> select​(java.lang.Iterable<T> iterable, 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, 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>>
      R
      select​(java.lang.Iterable<T> iterable, 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>>
      R
      select​(java.lang.Iterable<T> iterable, Predicate<? super T> predicate, R target, int batchSize, java.util.concurrent.ForkJoinPool executor, boolean allowReorderedResult)
      Same effect as Iterate.select(Iterable, Predicate), but executed in parallel batches, and writing output into the specified collection.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_PARALLEL_TASK_COUNT

        private static final int DEFAULT_PARALLEL_TASK_COUNT
      • FORK_JOIN_POOL

        private static final java.util.concurrent.ForkJoinPool FORK_JOIN_POOL
    • Constructor Detail

      • FJIterate

        private FJIterate()
    • Method Detail

      • forEachWithIndex

        public static <T> void forEachWithIndex​(java.lang.Iterable<T> iterable,
                                                ObjectIntProcedure<? super T> procedure)
        Iterate over the collection specified, in parallel batches using default runtime parameter values. The ObjectIntProcedure used must be stateless, or use concurrent aware objects if they are to be shared.

        e.g.

         Map<Integer, Object> chm = new ConcurrentHashMap<Integer, Object>();
         FJIterate.forEachWithIndex(collection, (each, index) -> chm.put(index, each));
         
      • forEachWithIndex

        public static <T,​PT extends ObjectIntProcedure<? super T>> void forEachWithIndex​(java.lang.Iterable<T> iterable,
                                                                                               PT procedure,
                                                                                               java.util.concurrent.ForkJoinPool 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>();
         FJIterate.forEachWithIndex(collection, (each, index) -> chm.put(index, each), executor);
         
        Parameters:
        executor - Use this executor for all execution.
      • forEachWithIndex

        public static <T,​PT extends ObjectIntProcedure<? super T>> void forEachWithIndex​(java.lang.Iterable<T> iterable,
                                                                                               PT 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 - The number of parallel tasks to submit to the executor.
        See Also:
        forEachWithIndex(Iterable, ObjectIntProcedure)
      • forEachWithIndex

        public static <T,​PT extends ObjectIntProcedure<? super T>> void forEachWithIndex​(java.lang.Iterable<T> iterable,
                                                                                               ObjectIntProcedureFactory<PT> procedureFactory,
                                                                                               Combiner<PT> combiner,
                                                                                               java.util.concurrent.ForkJoinPool executor)
      • forEachWithIndex

        public static <T,​PT extends ObjectIntProcedure<? super T>> void forEachWithIndex​(java.lang.Iterable<T> iterable,
                                                                                               ObjectIntProcedureFactory<PT> procedureFactory,
                                                                                               Combiner<PT> combiner,
                                                                                               int minForkSize,
                                                                                               int taskCount,
                                                                                               java.util.concurrent.ForkJoinPool executor)
      • forEachWithIndexInListOnExecutor

        public static <T,​PT extends ObjectIntProcedure<? super T>> void forEachWithIndexInListOnExecutor​(java.util.List<T> list,
                                                                                                               ObjectIntProcedureFactory<PT> procedureFactory,
                                                                                                               Combiner<PT> combiner,
                                                                                                               int minForkSize,
                                                                                                               int taskCount,
                                                                                                               java.util.concurrent.ForkJoinPool 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. The Procedure used must be stateless, or use concurrent aware objects if they are to be shared.

        e.g.

         Map<Object, Boolean> chm = new ConcurrentHashMap<Object, Boolean>();
         FJIterate.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. The Procedure used must be stateless, or use concurrent aware objects if they are to be shared.

        e.g.

         Map<Object, Boolean> chm = new ConcurrentHashMap<Object, Boolean>();
         FJIterate.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.ForkJoinPool executor)
      • forEach

        public static <T,​PT extends Procedure<? super T>> void forEach​(java.lang.Iterable<T> iterable,
                                                                             PT procedure,
                                                                             java.util.concurrent.ForkJoinPool executor)
        Iterate over the collection specified in parallel batches using default runtime parameter values and the specified executor. The Procedure used 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,​PT extends Procedure<? super T>> void forEach​(java.lang.Iterable<T> iterable,
                                                                             PT procedure,
                                                                             int minForkSize,
                                                                             int taskCount)
        Iterate over the collection specified in parallel batches using the specified minimum fork and task count sizes. The Procedure used 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 - The number of parallel tasks to submit to the executor.
        See Also:
        forEach(Iterable, Procedure)
      • forEach

        public static <T,​PT extends Procedure<? super T>> void forEach​(java.lang.Iterable<T> iterable,
                                                                             PT procedure,
                                                                             int minForkSize,
                                                                             int taskCount,
                                                                             java.util.concurrent.ForkJoinPool executor)
      • forEach

        public static <T,​PT extends Procedure<? super T>> void forEach​(java.lang.Iterable<T> iterable,
                                                                             ProcedureFactory<PT> procedureFactory,
                                                                             Combiner<PT> combiner,
                                                                             java.util.concurrent.ForkJoinPool executor)
      • forEach

        public static <T,​PT extends Procedure<? super T>> void forEach​(java.lang.Iterable<T> iterable,
                                                                             ProcedureFactory<PT> procedureFactory,
                                                                             Combiner<PT> combiner)
      • forEach

        public static <T,​PT extends Procedure<? super T>> void forEach​(java.lang.Iterable<T> iterable,
                                                                             ProcedureFactory<PT> procedureFactory,
                                                                             Combiner<PT> 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.
      • forEach

        public static <T,​PT extends Procedure<? super T>> void forEach​(java.lang.Iterable<T> iterable,
                                                                             ProcedureFactory<PT> blockFactory,
                                                                             Combiner<PT> combiner,
                                                                             int batchSize,
                                                                             java.util.concurrent.ForkJoinPool executor)
      • forEach

        public static <T,​PT extends Procedure<? super T>> void forEach​(java.lang.Iterable<T> iterable,
                                                                             ProcedureFactory<PT> procedureFactory,
                                                                             Combiner<PT> 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.
      • forEach

        public static <T,​PT extends Procedure<? super T>> void forEach​(java.lang.Iterable<T> iterable,
                                                                             ProcedureFactory<PT> procedureFactory,
                                                                             Combiner<PT> combiner,
                                                                             int minForkSize,
                                                                             int taskCount,
                                                                             java.util.concurrent.ForkJoinPool executor)
      • forEachInListOnExecutor

        public static <T,​PT extends Procedure<? super T>> void forEachInListOnExecutor​(java.util.List<T> list,
                                                                                             ProcedureFactory<PT> procedureFactory,
                                                                                             Combiner<PT> combiner,
                                                                                             int minForkSize,
                                                                                             int taskCount,
                                                                                             java.util.concurrent.ForkJoinPool executor)
      • forEachInBatchWithExecutor

        public static <T,​PT extends Procedure<? super T>> void forEachInBatchWithExecutor​(BatchIterable<T> batchIterable,
                                                                                                ProcedureFactory<PT> procedureFactory,
                                                                                                Combiner<PT> combiner,
                                                                                                int minForkSize,
                                                                                                int taskCount,
                                                                                                java.util.concurrent.ForkJoinPool executor)
      • executedInsideOfForEach

        static boolean executedInsideOfForEach()
      • select

        public static <T> java.util.Collection<T> select​(java.lang.Iterable<T> iterable,
                                                         Predicate<? super T> predicate)
        Same effect as Iterate.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 as Iterate.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 as Iterate.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.ForkJoinPool executor,
                                                                           boolean allowReorderedResult)
        Same effect as Iterate.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 as Iterate.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 as Iterate.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 as Iterate.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.ForkJoinPool executor,
                                                                           boolean allowReorderedResult)
      • count

        public static <T> int count​(java.lang.Iterable<T> iterable,
                                    Predicate<? super T> predicate)
        Same effect as Iterate.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.ForkJoinPool executor)
        Same effect as Iterate.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 as Iterate.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 as Iterate.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 as Iterate.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.ForkJoinPool executor,
                                                                                    boolean allowReorderedResult)
      • flatCollect

        public static <T,​V> java.util.Collection<V> flatCollect​(java.lang.Iterable<T> iterable,
                                                                      Function<? super T,​? extends java.lang.Iterable<V>> function)
      • flatCollect

        public static <T,​V> java.util.Collection<V> flatCollect​(java.lang.Iterable<T> iterable,
                                                                      Function<? super T,​? extends java.lang.Iterable<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,​? extends java.lang.Iterable<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,​? extends java.lang.Iterable<V>> function,
                                                                                        R target,
                                                                                        int batchSize,
                                                                                        java.util.concurrent.ForkJoinPool 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,
                                                                    boolean allowReorderedResult)
        Same effect as Iterate.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 as Iterate.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.ForkJoinPool executor,
                                                                                      boolean allowReorderedResult)
      • 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.ForkJoinPool 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.ForkJoinPool 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.ForkJoinPool 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.ForkJoinPool executor)
      • groupBy

        public static <K,​V> MutableMultimap<K,​V> groupBy​(java.lang.Iterable<V> iterable,
                                                                     Function<? super V,​? extends K> function)
        Same effect as Iterate.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 as Iterate.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 as Iterate.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.ForkJoinPool executor)
        Same effect as Iterate.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.ForkJoinPool executor)
        Same effect as Iterate.groupBy(Iterable, Function), but executed in parallel batches, and writing output into a SynchronizedPutFastListMultimap.