Class GridIterator.SquareSpiral
java.lang.Object
com.github.yellowstonegames.grid.GridIterator
com.github.yellowstonegames.grid.GridIterator.SquareSpiral
- Enclosing class:
GridIterator
Iterates in a square spiral going outward from a starting position. Iteration stops once a position would be
out of bounds.
-
Nested Class Summary
Nested classes/interfaces inherited from class GridIterator
GridIterator.CenteredSquare, GridIterator.SquareSpiral, GridIterator.VerticalUp -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected intprotected Coordprotected intprotected intFields inherited from class GridIterator
height, width -
Constructor Summary
ConstructorsConstructorDescriptionSquareSpiral(int width, int height, int x, int y) An iterator to iterate in the square of sizesizearound(x, y).SquareSpiral(int width, int height, Coord start) An iterator to iterate in the square of sizesizearoundstart. -
Method Summary
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterator
forEachRemaining
-
Field Details
-
previous
-
xStart
protected int xStart -
yStart
protected int yStart -
index
protected int index -
done
protected boolean done
-
-
Constructor Details
-
SquareSpiral
public SquareSpiral(int width, int height, int x, int y) An iterator to iterate in the square of sizesizearound(x, y).- Parameters:
width- The map's widthheight- The map's heightx- The starting x coordinate.y- The starting y coordinate.- Throws:
IllegalStateException- Ifwidth <= 0 || height <= 0 || size < 0.
-
SquareSpiral
An iterator to iterate in the square of sizesizearoundstart.- Parameters:
width- The grid's widthheight- The grid's heightstart- The starting coordinate.
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
-
remove
public void remove() -
findNext
-
findNextCandidate
-
isInGrid
protected boolean isInGrid(int x, int y)
-