Class SpiralIterator

java.lang.Object
net.pl3x.map.core.util.SpiralIterator
All Implemented Interfaces:
Iterator<Point>

public class SpiralIterator extends Object implements Iterator<Point>
An iterator that spirals around a center point in a clockwise pattern

Example using a radius of 3:

   30 31 32 33 34 35 36
   29 12 13 14 15 16 37
   28 11 02 03 04 17 38
   27 10 01 00 05 18 39
   26 09 08 07 06 19 40
   25 24 23 22 21 20 41
   48 47 46 45 44 43 42
 
  • Field Details

    • currentX

      protected int currentX
    • currentZ

      protected int currentZ
    • totalStepsInLeg

      protected long totalStepsInLeg
    • currentStepInLeg

      protected long currentStepInLeg
    • legAxis

      protected long legAxis
    • direction

      protected SpiralIterator.Direction direction
  • Constructor Details

    • SpiralIterator

      public SpiralIterator(int centerX, int centerZ)
      Constructs a new SpiralIterator with given center point and radius
      Parameters:
      centerX - center x point
      centerZ - center z point
  • Method Details