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 intcurrentRadiusThe current radius of the iteration.private intnThe current index in the circle with the current radius:private intradiusThe maximum radius.private intxThe current position in the circle.private intyThe 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 intgetCurrentRadius()Gets the current radius of the circle.booleanhasNext()Tilenext()private voidnextTile()Finds the next position.voidremove()
-
-
-
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 centerTileof 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
CircleIteratorwas initialized with.
-
nextTile
private void nextTile()
Finds the next position.
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<Tile>
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<Tile>
-
-