|
SSJ V. 2.6.2. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PointSetIterator
Objects of classes that implement this interface are iterators
that permit one to enumerate
(or observe) the successive points of a point set and the successive
coordinates of these points.
Each PointSetIterator
is associated with a given point set
and maintains a current point index i and a current coordinate
index j, which are both initialized to zero.
Successive coordinates can be accessed one or many at a time by the methods
nextCoordinate
and nextCoordinates
, respectively.
The current coordinate index j can be set explicitely by
setCurCoordIndex
and resetCurCoordIndex
.
Similar methods are available for resetting and accessing the current point.
The method nextPoint
permits one to
enumerate the successive points in natural order.
This class also implements the RandomStream
interface.
This permits one to replace random numbers by the coordinates of
(randomized) quasi-Monte Carlo points without changing the code that calls
the generators in a simulation program.
That is, the same simulation program can be used for both Monte Carlo
and quasi-Monte Carlo simulations.
The method nextDouble
does exactly the same as
nextCoordinate
, it returns the current coordinate of the
current point and advances the current coordinate by one.
The substreams correspond to the points, so
resetStartSubstream
resets the current point coordinate to zero,
resetNextSubstream
resets the iterator to the next point, and
resetStartStream
resets the iterator to the first point of
the point set.
There can be several iterators over the same point set. These iterators are independent from each other. Classes that implement this interface must maintain enough information so that each iterator is unaffected by other iterator's operations. However, the iterator does not need to be independent of the underlying point set. If the point set is modified (e.g., randomized), the iterator may continue to work as usual.
Point set iterators are implemented as inner classes because this gives a direct access to the private members (or variables) of the class. This is important for efficiency. They are quite similar to the iterators in Java collections.
Method Summary | |
---|---|
int |
getCurCoordIndex()
Returns the index j of the current coordinate. |
int |
getCurPointIndex()
Returns the index i of the current point. |
boolean |
hasNextCoordinate()
Returns true if the current point has another coordinate. |
boolean |
hasNextPoint()
Returns true if there is a next point. |
double |
nextCoordinate()
Returns the current coordinate ui, j and advances to the next one. |
void |
nextCoordinates(double[] p,
int d)
Returns the next d coordinates of the current point in p and advances the current coordinate index by d. |
int |
nextPoint(double[] p,
int d)
Returns the first d coordinates of the current point in p, advances to the next point, and returns the index of the new current point. |
void |
resetCurCoordIndex()
Equivalent to setCurCoordIndex (0). |
void |
resetCurPointIndex()
Equivalent to setCurPointIndex (0). |
int |
resetToNextPoint()
Increases the current point index by 1 and returns its new value. |
void |
setCurCoordIndex(int j)
Sets the current coordinate index to j, so that the next calls to nextCoordinate or nextCoordinates
will return the values
ui, j, ui, j+1,..., where i is the
index of the current point. |
void |
setCurPointIndex(int i)
Resets the current point index to i and the current coordinate index to zero. |
Methods inherited from interface umontreal.iro.lecuyer.rng.RandomStream |
---|
nextArrayOfDouble, nextArrayOfInt, nextDouble, nextInt, resetNextSubstream, resetStartStream, resetStartSubstream, toString |
Method Detail |
---|
void setCurCoordIndex(int j)
nextCoordinate
or nextCoordinates
will return the values
ui, j, ui, j+1,..., where i is the
index of the current point.
j
- index of the new current coordinatevoid resetCurCoordIndex()
setCurCoordIndex
(0).
int getCurCoordIndex()
boolean hasNextCoordinate()
double nextCoordinate()
NoSuchElementException
.
NoSuchElementException
- if no such coordinate is availablevoid nextCoordinates(double[] p, int d)
nextCoordinate
.
p
- array to be filled with the coordinates, starting at index 0d
- number of coordinates to get
NoSuchElementException
- if there are not enough
remaining coordinates in the current pointvoid setCurPointIndex(int i)
i
- new index of the current pointvoid resetCurPointIndex()
setCurPointIndex
(0).
int resetToNextPoint()
int getCurPointIndex()
boolean hasNextPoint()
int nextPoint(double[] p, int d)
Specialized implementations of this method often allow for increased efficiency, e.g., for cycle-based point sets where the cycles (but not the points) are stored explicitly or for digital nets by allowing non-incremental point enumerations via Gray-code counters.
p
- array to be filled with the coordinates,
starting from array index 0d
- number of coordinates to return
NoSuchElementException
- if there are not enough coordinates
available in the current point for filling p
|
SSJ V. 2.6.2. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |