public class ForkJoinSolver extends SequentialSolver
ForkJoinSolver
implements a solver for
Maze
objects using a fork/join multi-thread
depth-first search.
Instances of ForkJoinSolver
should be run by a
ForkJoinPool
object.
forkAfter, frontier, maze, predecessor, start, visited
Constructor and Description |
---|
ForkJoinSolver(Maze maze)
Creates a solver that searches in
maze from the
start node to a goal. |
ForkJoinSolver(Maze maze,
int forkAfter)
Creates a solver that searches in
maze from the
start node to a goal, forking after a given number of visited
nodes. |
Modifier and Type | Method and Description |
---|---|
java.util.List<java.lang.Integer> |
compute()
Searches for and returns the path, as a list of node
identifiers, that goes from the start node to a goal node in
the maze.
|
initStructures, pathFromTo
adapt, adapt, adapt, cancel, compareAndSetForkJoinTaskTag, complete, completeExceptionally, fork, get, get, getException, getForkJoinTaskTag, getPool, getQueuedTaskCount, getSurplusQueuedTaskCount, helpQuiesce, inForkJoinPool, invoke, invokeAll, invokeAll, invokeAll, isCancelled, isCompletedAbnormally, isCompletedNormally, isDone, join, peekNextLocalTask, pollNextLocalTask, pollTask, quietlyComplete, quietlyInvoke, quietlyJoin, reinitialize, setForkJoinTaskTag, tryUnfork
public ForkJoinSolver(Maze maze)
maze
from the
start node to a goal.maze
- the maze to be searchedpublic ForkJoinSolver(Maze maze, int forkAfter)
maze
from the
start node to a goal, forking after a given number of visited
nodes.maze
- the maze to be searchedforkAfter
- the number of steps (visited nodes) after
which a parallel task is forked; if
forkAfter <= 0
the solver never
forks new taskspublic java.util.List<java.lang.Integer> compute()
null
.compute
in class SequentialSolver
null
if such a path cannot
be found.