|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcore.field.RandomGridIterator
Iterates over an integer, rectangular grid in a pseudo-random order. Because it is difficult to quickly produce a fully random ordering of all the grid points, this class uses a pseudo-random technique: The grid is divided evenly into square blocks, and a random point is chosen in the top-left block. The corresponding points in all the rest of the blocks are next in the sequence. Points are chosen in the block in a truly random fashion until all the points on the grid are covered.
Field Summary | |
private int |
blocksize
|
private int |
coverage
|
private static int |
coveragelimit
|
private boolean[][] |
covered
|
private int |
gx
|
private int |
gy
|
private java.util.Random |
random
|
private Vec2 |
v
|
private int |
x
|
private int |
xmax
|
private int |
xmin
|
private int |
y
|
private int |
ymax
|
private int |
ymin
|
Constructor Summary | |
RandomGridIterator(int width,
int height)
Constructs a RandomGridIterator that iterates pseudo-randomly over the integer grid [0, width-1] x [0, height-1]. |
|
RandomGridIterator(int xorigin,
int yorigin,
int width,
int height)
Constructs a RandomGridIterator that iterates pseudo-randomly over the integer grid [xorigin, xorigin+width-1] x [yorigin, yorigin+height-1]. |
|
RandomGridIterator(int xorigin,
int yorigin,
int width,
int height,
java.util.Random random)
Constructs a RandomGridIterator that iterates pseudo-randomly over the integer grid [xorigin, xorigin+width-1] x [yorigin, yorigin+height-1] using the random sequence generator 'random'. |
|
RandomGridIterator(int width,
int height,
java.util.Random random)
Constructs a RandomGridIterator. |
Method Summary | |
private void |
Initialize()
|
Vec2 |
next()
Returns: null if there are no more points in the sequence, else a Vec2 whose value is the next point. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static int coveragelimit
private int xmin
private int xmax
private int ymin
private int ymax
private int blocksize
private int coverage
private int gx
private int gy
private int x
private int y
private boolean[][] covered
private java.util.Random random
private Vec2 v
Constructor Detail |
public RandomGridIterator(int width, int height)
public RandomGridIterator(int width, int height, java.util.Random random)
public RandomGridIterator(int xorigin, int yorigin, int width, int height)
public RandomGridIterator(int xorigin, int yorigin, int width, int height, java.util.Random random)
Method Detail |
public Vec2 next()
next
in interface Vec2Iterator
private void Initialize()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |