Package net.sf.freecol.common.model
Class Map.CircleIterator
- java.lang.Object
-
- net.sf.freecol.common.model.Map.CircleIterator
-
- All Implemented Interfaces:
java.util.Iterator<Tile>
- Enclosing class:
- Map
private final class Map.CircleIterator extends java.lang.Object implements java.util.Iterator<Tile>
An iterator returning positions in a spiral starting at a given center tile. The center tile is never included in the returned tiles, and all returned tiles are valid.
-
-
Field Summary
Fields Modifier and Type Field Description private int
currentRadius
The current radius of the iteration.private int
n
The current index in the circle with the current radius:private int
radius
The maximum radius.private int
x
The current position in the circle.private int
y
The current position in the circle.
-
Constructor Summary
Constructors Constructor Description CircleIterator(Tile center, boolean isFilled, int radius)
Create a new Circle Iterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getCurrentRadius()
Gets the current radius of the circle.boolean
hasNext()
Tile
next()
private void
nextTile()
Finds the next position.void
remove()
-
-
-
Field Detail
-
radius
private final int radius
The maximum radius.
-
currentRadius
private int currentRadius
The current radius of the iteration.
-
n
private int n
The current index in the circle with the current radius:
-
x
private int x
The current position in the circle.
-
y
private int y
The current position in the circle.
-
-
Constructor Detail
-
CircleIterator
public CircleIterator(Tile center, boolean isFilled, int radius)
Create a new Circle Iterator.- Parameters:
center
- The centerTile
of the circle.isFilled
- True to get all of the positions within the circle.radius
- The radius of the circle.
-
-
Method Detail
-
getCurrentRadius
public int getCurrentRadius()
Gets the current radius of the circle.- Returns:
- The distance from the center tile this
CircleIterator
was initialized with.
-
nextTile
private void nextTile()
Finds the next position.
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<Tile>
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<Tile>
-
-