Difference between revisions of "Fork Loop Assignment"
Jump to navigation
Jump to search
Line 33: | Line 33: | ||
{{RightToolForTheJob|The method toSquareRoots accepts an array parameter and returns an array. | {{RightToolForTheJob|The method toSquareRoots accepts an array parameter and returns an array. | ||
− | [https://www.cse.wustl.edu/~dennis.cosgrove/courses/cse231/current/apidocs/fj/FJ.html#join_fork_loop(java.util.function.IntFunction,int,int,fj.api.TaskIntFunction) join_fork_loop(returnValueArrayCreator, array, task)] will perform exactly what we want, but we need to also pass | + | [https://www.cse.wustl.edu/~dennis.cosgrove/courses/cse231/current/apidocs/fj/FJ.html#join_fork_loop(java.util.function.IntFunction,int,int,fj.api.TaskIntFunction) join_fork_loop(returnValueArrayCreator, array, task)] will perform exactly what we want, but we need to also pass an array creator. |
− | How do you specify an returnValueArrayCreator for <code>Double[]</code>? {{Spoiler|<code>Double[]::new</code>}}}} | + | How do you tersely specify an returnValueArrayCreator for <code>Double[]</code>? {{Spoiler|<code>Double[]::new</code>}}}} |
===client=== | ===client=== |
Latest revision as of 02:32, 11 September 2023
Contents
Motivation
There are many incantations of the fork_loop. We gain experience with selecting the right one for two scenarios.
Background
Code To Use
FJ
class FJ<E>
Code To Implement
Echoes
class: | Echoes.java | |
methods: | toEchoes | |
package: | forkloop.group | |
source folder: | student/src/main/java |
toEchoes
method: public static List<String> toEchoes(List<String> texts)
(parallel implementation required)
for each text in parallel, produce text + " " + text
.
Right Tool For The Job Requirement | |
---|---|
The toEchoes method accepts a List<String> parameter and returns a List<String>. List<E> is an Iterable<E>, so instances of List<E> can be passed to join_fork_loop(iterable, task). |
client
class: | EchoClient.java | DEMO: |
methods: | main | |
package: | forkloop.client | |
source folder: | src/main/java |
SquareRoots
class: | SquareRoots.java | |
methods: | toSquareRoots | |
package: | forkloop.group | |
source folder: | student/src/main/java |
toSquareRoots
method: public static Double[] toSquareRoots(Double[] values)
(parallel implementation required)
Right Tool For The Job Requirement | |||
---|---|---|---|
The method toSquareRoots accepts an array parameter and returns an array.
join_fork_loop(returnValueArrayCreator, array, task) will perform exactly what we want, but we need to also pass an array creator. How do you tersely specify an returnValueArrayCreator for
|
client
class: | SquareRootClient.java | DEMO: |
methods: | main | |
package: | forkloop.client | |
source folder: | src/main/java |
Testing
class: | _ForkLoopTestSuite.java | |
package: | forkloop.group | |
source folder: | testing/src/test/java |