Skip to content

Commit

Permalink
Merge pull request #1294 from donraab/master
Browse files Browse the repository at this point in the history
Update ParallelIterate and FJIterate JavaDoc to use lambdas.
  • Loading branch information
donraab committed Apr 11, 2022
2 parents eb3e2f1 + 9cf8cbc commit 55dfd9f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 71 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Goldman Sachs.
* Copyright (c) 2022 Goldman Sachs and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompany this distribution.
Expand Down Expand Up @@ -85,19 +85,11 @@ private FJIterate()
* <p>
* e.g.
* <pre>
* {@code final ConcurrentMutableMap<Integer, Object> chm = new ConcurrentHashMap<Integer, Object>();}
* FJIterate.<b>forEachWithIndex</b>(collection, new ObjectIntProcedure()
* {
* public void value(Object object, int index)
* {
* chm.put(index, object);
* }
* });
* Map&lt;Integer, Object&gt; chm = new ConcurrentHashMap&lt;Integer, Object&gt;();
* FJIterate.<b>forEachWithIndex</b>(collection, (each, index) -> chm.put(index, each));
* </pre>
*/
public static <T> void forEachWithIndex(
Iterable<T> iterable,
ObjectIntProcedure<? super T> procedure)
public static <T> void forEachWithIndex(Iterable<T> iterable, ObjectIntProcedure<? super T> procedure)
{
FJIterate.forEachWithIndex(iterable, procedure, FJIterate.FORK_JOIN_POOL);
}
Expand All @@ -108,14 +100,8 @@ public static <T> void forEachWithIndex(
* is executed against the specified executor.
*
* <pre>e.g.
* {@code final ConcurrentMutableMap<Integer, Object> chm = new ConcurrentHashMap<Integer, Object>();}
* FJIterate.<b>forEachWithIndex</b>(collection, new ObjectIntProcedure()
* {
* public void value(Object object, int index)
* {
* chm.put(index, object);
* }
* }, executor);
* Map&lt;Integer, Object&gt; chm = new ConcurrentHashMap&lt;Integer, Object&gt;();
* FJIterate.<b>forEachWithIndex</b>(collection, (each, index) -> chm.put(index, each), executor);
* </pre>
*
* @param executor Use this executor for all execution.
Expand Down Expand Up @@ -241,14 +227,8 @@ public static <T, PT extends ObjectIntProcedure<? super T>> void forEachWithInde
* <p>
* e.g.
* <pre>
* {@code final ConcurrentMutableMap<Object, Boolean> chm = new ConcurrentHashMap<Object, Boolean>();}
* FJIterate.<b>forEach</b>(collection, new Procedure()
* {
* public void value(Object object)
* {
* chm.put(object, Boolean.TRUE);
* }
* });
* Map&lt;Object, Boolean&gt; chm = new ConcurrentHashMap&lt;Object, Boolean&gt;();
* FJIterate.<b>forEach</b>(collection, each -> chm.put(each, Boolean.TRUE));
* </pre>
*/
public static <T> void forEach(Iterable<T> iterable, Procedure<? super T> procedure)
Expand All @@ -262,14 +242,8 @@ public static <T> void forEach(Iterable<T> iterable, Procedure<? super T> proced
* <p>
* e.g.
* <pre>
* {@code final ConcurrentMutableMap<Object, Boolean> chm = new ConcurrentHashMap<Object, Boolean>();}
* FJIterate.<b>forEachBatchSize</b>(collection, new Procedure()
* {
* public void value(Object object)
* {
* chm.put(object, Boolean.TRUE);
* }
* }, 100);
* Map&lt;Object, Boolean&gt; chm = new ConcurrentHashMap&lt;Object, Boolean&gt;();
* FJIterate.<b>forEachBatchSize</b>(collection, each -> chm.put(each, Boolean.TRUE), 100);
* </pre>
*/
public static <T> void forEach(Iterable<T> iterable, Procedure<? super T> procedure, int batchSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,11 @@ static void shutdownExecutor()
* <p>
* e.g.
* <pre>
* final Map&lt;Integer, Object&gt; chm = new ConcurrentHashMap&lt;Integer, Object&gt;();
* ParallelIterate.<b>forEachWithIndex</b>(collection, new ObjectIntProcedure()
* {
* public void value(Object object, int index)
* {
* chm.put(index, object);
* }
* });
* Map&lt;Integer, Object&gt; chm = new ConcurrentHashMap&lt;Integer, Object&gt;();
* ParallelIterate.<b>forEachWithIndex</b>(collection, (each, index) -> chm.put(index, each));
* </pre>
*/
public static <T> void forEachWithIndex(
Iterable<T> iterable,
ObjectIntProcedure<? super T> objectIntProcedure)
public static <T> void forEachWithIndex(Iterable<T> iterable, ObjectIntProcedure<? super T> objectIntProcedure)
{
ParallelIterate.forEachWithIndex(iterable, objectIntProcedure, ParallelIterate.EXECUTOR_SERVICE);
}
Expand All @@ -119,14 +111,8 @@ public static <T> void forEachWithIndex(
* is executed against the specified executor.
*
* <pre>e.g.
* final Map&lt;Integer, Object&gt; chm = new ConcurrentHashMap&lt;Integer, Object&gt;();
* ParallelIterate.<b>forEachWithIndex</b>(collection, new ObjectIntProcedure()
* {
* public void value(Object object, int index)
* {
* chm.put(index, object);
* }
* }, executor);
* Map&lt;Integer, Object&gt; chm = new ConcurrentHashMap&lt;Integer, Object&gt;();
* ParallelIterate.<b>forEachWithIndex</b>(collection, (each, index) -> chm.put(index, each), executor);
* </pre>
*
* @param executor Use this executor for all execution.
Expand Down Expand Up @@ -264,14 +250,8 @@ public static <T, BT extends ObjectIntProcedure<? super T>> void forEachWithInde
* <p>
* e.g.
* <pre>
* final Map&lt;Object, Boolean&gt; chm = new ConcurrentHashMap&lt;Object, Boolean&gt;();
* ParallelIterate.<b>forEach</b>(collection, new Procedure()
* {
* public void value(Object object)
* {
* chm.put(object, Boolean.TRUE);
* }
* });
* Map&lt;Object, Boolean&gt; chm = new ConcurrentHashMap&lt;Object, Boolean&gt;();
* ParallelIterate.<b>forEach</b>(collection, each -> chm.put(each, Boolean.TRUE));
* </pre>
*/
public static <T> void forEach(Iterable<T> iterable, Procedure<? super T> procedure)
Expand All @@ -285,14 +265,8 @@ public static <T> void forEach(Iterable<T> iterable, Procedure<? super T> proced
* <p>
* e.g.
* <pre>
* final Map&lt;Object, Boolean&gt; chm = new ConcurrentHashMap&lt;Object, Boolean&gt;();
* ParallelIterate.<b>forEachBatchSize</b>(collection, new Procedure()
* {
* public void value(Object object)
* {
* chm.put(object, Boolean.TRUE);
* }
* }, 100);
* Map&lt;Object, Boolean&gt; chm = new ConcurrentHashMap&lt;Object, Boolean&gt;();
* ParallelIterate.<b>forEachBatchSize</b>(collection, each -> chm.put(each, Boolean.TRUE), 100);
* </pre>
*/
public static <T> void forEach(Iterable<T> iterable, Procedure<? super T> procedure, int batchSize)
Expand Down

0 comments on commit 55dfd9f

Please sign in to comment.