public static <T, V, R extends Collection<V>> R flatCollect( Iterable<T> iterable, Function<? super T, Collection<V>> function, R target, int batchSize, Executor executor, boolean allowReorderedResult) { int size = Iterate.sizeOf(iterable); int taskCount = ParallelIterate.calculateTaskCount(iterable, batchSize); int taskSize = size / taskCount; FlatCollectProcedureCombiner<T, V> combiner = new FlatCollectProcedureCombiner<>(iterable, target, size, allowReorderedResult); FlatCollectProcedureFactory<T, V> procedureFactory = new FlatCollectProcedureFactory<>(function, taskSize); ParallelIterate.forEach( iterable, procedureFactory, combiner, batchSize, taskCount, executor); return (R) combiner.getResult(); }
public static <T, V, R extends Collection<V>> R flatCollect( Iterable<T> iterable, Function<? super T, Collection<V>> function, R target, int batchSize, Executor executor, boolean allowReorderedResult) { int size = Iterate.sizeOf(iterable); int taskCount = ParallelIterate.calculateTaskCount(iterable, batchSize); int taskSize = size / taskCount; FlatCollectProcedureCombiner<T, V> combiner = new FlatCollectProcedureCombiner<>(iterable, target, size, allowReorderedResult); FlatCollectProcedureFactory<T, V> procedureFactory = new FlatCollectProcedureFactory<>(function, taskSize); ParallelIterate.forEach( iterable, procedureFactory, combiner, batchSize, taskCount, executor); return (R) combiner.getResult(); }
public static <T, V, R extends Collection<V>> R flatCollect( Iterable<T> iterable, Function<? super T, ? extends Iterable<V>> function, R target, int batchSize, ForkJoinPool executor, boolean allowReorderedResult) { int size = Iterate.sizeOf(iterable); int taskSize = size / FJIterate.DEFAULT_PARALLEL_TASK_COUNT; FlatCollectProcedureCombiner<T, V> combiner = new FlatCollectProcedureCombiner<>(iterable, target, size, allowReorderedResult); FlatCollectProcedureFactory<T, V> procedureFactory = new FlatCollectProcedureFactory<>(function, taskSize); int taskCount = FJIterate.calculateTaskCount(size, batchSize); FJIterate.forEach(iterable, procedureFactory, combiner, batchSize, taskCount, executor); return (R) combiner.getResult(); }
public static <T, V, R extends Collection<V>> R flatCollect( Iterable<T> iterable, Function<? super T, Collection<V>> function, R target, int batchSize, Executor executor, boolean allowReorderedResult) { int size = Iterate.sizeOf(iterable); int taskCount = ParallelIterate.calculateTaskCount(iterable, batchSize); int taskSize = size / taskCount; FlatCollectProcedureCombiner<T, V> combiner = new FlatCollectProcedureCombiner<>(iterable, target, size, allowReorderedResult); FlatCollectProcedureFactory<T, V> procedureFactory = new FlatCollectProcedureFactory<>(function, taskSize); ParallelIterate.forEach( iterable, procedureFactory, combiner, batchSize, taskCount, executor); return (R) combiner.getResult(); }