Class BoxSurfaceIterator
java.lang.Object
net.apartium.cocoabeans.space.iterator.BoxSurfaceIterator
@AvailableSince("0.0.49")
public final class BoxSurfaceIterator
extends Object
implements Iterator<Position>
Iterates over all positions on the surface of an axis-aligned box.
A position is included if at least one of its coordinates is equal to the minimum or maximum bound of the box. Interior positions are skipped.
Positions are emitted face by face. The iterator adjusts the coordinate ranges per face so edges and corners are not returned more than once.
If min and max describe the same position, the iterator
returns that single position.
-
Constructor Summary
ConstructorsConstructorDescriptionBoxSurfaceIterator(int radius) Creates an iterator over a cube shell centered at 0 with the given radius.BoxSurfaceIterator(int min, int max) Creates an iterator over a cube shell in the range[min, max]using the defaultAxisOrder.XYZ.BoxSurfaceIterator(AxisOrder axisOrder, int min, int max) Creates an iterator over a cube shell in the range[min, max].BoxSurfaceIterator(AxisOrder axisOrder, Position min, Position max) Creates an iterator over the surface of a rectangular box. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
BoxSurfaceIterator
public BoxSurfaceIterator(int radius) Creates an iterator over a cube shell centered at 0 with the given radius.- Parameters:
radius- the cube radius (range will be[-radius, radius])
-
BoxSurfaceIterator
public BoxSurfaceIterator(int min, int max) Creates an iterator over a cube shell in the range[min, max]using the defaultAxisOrder.XYZ.- Parameters:
min- the minimum coordinate (inclusive)max- the maximum coordinate (inclusive)
-
BoxSurfaceIterator
Creates an iterator over a cube shell in the range[min, max].- Parameters:
axisOrder- the axis order used to construct positionsmin- the minimum coordinate (inclusive)max- the maximum coordinate (inclusive)- Throws:
IllegalArgumentException- ifmax < minNullPointerException- ifaxisOrderis null
-
BoxSurfaceIterator
Creates an iterator over the surface of a rectangular box.The given bounds are normalized with
Position.floor()and then stored as immutable positions.- Parameters:
axisOrder- the axis order used when constructing returned positionsmin- the minimum corner, inclusivemax- the maximum corner, inclusive- Throws:
IllegalArgumentException- if any coordinate inmaxis smaller than the corresponding coordinate inminNullPointerException- ifaxisOrder,min, ormaxisnull
-
-
Method Details
-
hasNext
public boolean hasNext()Returns whether another surface position is available. -
next
Returns the next surface position.- Specified by:
nextin interfaceIterator<Position>- Returns:
- the next position on the box surface
- Throws:
NoSuchElementException- if no more positions are available
-
peek
Returns the next surface position without advancing the iterator.- Returns:
- the next position on the box surface
-