net.sf.freecol.common.model
Class Map.CircleIterator

java.lang.Object
  extended by net.sf.freecol.common.model.Map.CircleIterator
All Implemented Interfaces:
java.util.Iterator<Map.Position>
Enclosing class:
Map

public final class Map.CircleIterator
extends java.lang.Object

An interator returning positions in a spiral starting at a given center tile. The center tile is never included in the positions returned, and all returned positions are valid.

See Also:
Map.Position

Constructor Summary
Map.CircleIterator(Map.Position center, boolean isFilled, int radius)
          The constructor to use.
 
Method Summary
 int getCurrentRadius()
          Returns the current radius of the circle.
 boolean hasNext()
          Determine if the iterator has another position in it.
 Map.Position nextPosition()
          Obtains the next position.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Map.CircleIterator

public Map.CircleIterator(Map.Position center,
                          boolean isFilled,
                          int radius)
The constructor to use.

Parameters:
center - The center 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()
Returns the current radius of the circle.

Returns:
The distance from the center tile this CircleIterator was initialized with.

hasNext

public boolean hasNext()
Determine if the iterator has another position in it.

Returns:
true of there is another position and false otherwise.

nextPosition

public Map.Position nextPosition()
Obtains the next position.

Returns:
The next position. This position is guaranteed to be valid.