public abstract class BreadthFirstSearch extends java.lang.Object implements Operation
visit(BlockVector3)
. The search continues
to a certain adjacent point provided that the method
isVisitable(BlockVector3, BlockVector3)
returns true for that point.
As an abstract implementation, this class can be used to implement functionality that starts at certain points and extends outward from those points.
warnedDeprecatedClasses
Modifier | Constructor and Description |
---|---|
protected |
BreadthFirstSearch(RegionFunction function)
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addAxes()
Add the directions along the axes as directions to visit.
|
protected void |
addDiagonal()
Add the diagonal directions as directions to visit.
|
void |
cancel()
Abort the current task.
|
int |
getAffected()
Get the number of affected objects.
|
protected java.util.Collection<BlockVector3> |
getDirections()
Get the list of directions will be visited.
|
java.lang.Iterable<com.sk89q.worldedit.util.formatting.text.Component> |
getStatusMessages()
Gets an iterable of messages that describe the current status of the
operation.
|
protected abstract boolean |
isVisitable(BlockVector3 from,
BlockVector3 to)
Return whether the given 'to' block should be visited, starting from the
'from' block.
|
Operation |
resume(RunContext run)
Complete the next step.
|
void |
visit(BlockVector3 position)
Add the given location to the list of locations to visit, provided
that it has not been visited.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addStatusMessages
protected BreadthFirstSearch(RegionFunction function)
function
- the function to apply to visited blocksprotected java.util.Collection<BlockVector3> getDirections()
Directions are BlockVector3
s that determine
what adjacent points area available. Vectors should not be
unit vectors. An example of a valid direction is
BlockVector3.at(1, 0, 1)
.
The list of directions can be cleared.
protected void addAxes()
protected void addDiagonal()
public void visit(BlockVector3 position)
isVisitable(BlockVector3, BlockVector3)
.
This method should be used before the search begins, because if the position does fail the test, and the search has already visited it (because it is connected to another root point), the search will mark the position as "visited" and a call to this method will do nothing.
position
- the positionprotected abstract boolean isVisitable(BlockVector3 from, BlockVector3 to)
from
- the origin blockto
- the block under questionpublic int getAffected()
public Operation resume(RunContext run) throws WorldEditException
Operation
resume
in interface Operation
run
- describes information about the current runWorldEditException
- an errorpublic void cancel()
Operation
Operation.resume(RunContext)
should not be called at any point in the
future. This method should not be called after successful completion of
the operation. This method must be called if the operation is
interrupted before completion.public java.lang.Iterable<com.sk89q.worldedit.util.formatting.text.Component> getStatusMessages()
Operation
getStatusMessages
in interface Operation