SSJ
V. labo.

umontreal.iro.lecuyer.hups
Interface PointSetIterator

All Superinterfaces:
RandomStream
All Known Implementing Classes:
CycleBasedPointSet.CycleBasedPointSetIterator, CycleBasedPointSetBase2.CycleBasedPointSetBase2Iterator

public interface PointSetIterator
extends RandomStream

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. This could be used to skip some coordinates for each point, for example. 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()
          .
 int getCurPointIndex()
          .
 boolean hasNextCoordinate()
          .
 boolean hasNextPoint()
          .
 double nextCoordinate()
          .
 void nextCoordinates(double[] p, int d)
          .
 int nextPoint(double[] p, int d)
          .
 int nextPoint(double[] p, int fromDim, int d)
          .
 void resetCurCoordIndex()
          .
 void resetCurPointIndex()
          .
 int resetToNextPoint()
          .
 void setCurCoordIndex(int j)
          .
 void setCurPointIndex(int i)
          .
 
Methods inherited from interface umontreal.iro.lecuyer.rng.RandomStream
nextArrayOfDouble, nextArrayOfInt, nextDouble, nextInt, resetNextSubstream, resetStartStream, resetStartSubstream, toString
 

Method Detail

setCurCoordIndex

void setCurCoordIndex(int j)
. \begin{tabb}
 Sets the current coordinate index to $j$, so that
 the next calls...
 ...n be useful to skip certain coordinates for each point, for example.
 \end{tabb}
jindex of the new current coordinate


resetCurCoordIndex

void resetCurCoordIndex()
. \begin{tabb}
 Equivalent to \method{setCurCoordIndex}{}~\texttt{(0)}.
 \end{tabb}


getCurCoordIndex

int getCurCoordIndex()
. \begin{tabb}
 Returns the index $j$\ of the current coordinate. This may be useful,
 e.g., for testing if enough coordinates are still available.
 \end{tabb}
index of the current coordinate


hasNextCoordinate

boolean hasNextCoordinate()
. \begin{tabb}
 Returns \texttt{true} if the current point has another coordinate.
 This can be useful for testing if coordinates are still available.
 \end{tabb}
true if the current point has another coordinate


nextCoordinate

double nextCoordinate()
. \begin{tabb}
 Returns the current coordinate $u_{i,j}$\ and advances to the next...
 ...s), it throws a
 \externalclass{java.util}{NoSuchElementException}.
 \end{tabb}
value of the current coordinate NoSuchElementExceptionif no such coordinate is available


nextCoordinates

void nextCoordinates(double[] p,
                     int d)
. \begin{tabb}
 Returns the next \texttt{d} coordinates of the current point in \t...
 ...t{NoSuchElementException} is thrown, as in \method{nextCoordinate}{}.
 \end{tabb}
parray to be filled with the coordinates, starting at index 0 dnumber of coordinates to get NoSuchElementExceptionif there are not enough remaining coordinates in the current point


setCurPointIndex

void setCurPointIndex(int i)
. \begin{tabb}
 Resets the current point index to $i$\ and the current coordinate ...
 ...ised here, but only later if we
 ask for a new coordinate or point.
 \end{tabb}
inew index of the current point


resetCurPointIndex

void resetCurPointIndex()
. \begin{tabb}
 Equivalent to \method{setCurPointIndex}{}~\texttt{(0)}.
 \end{tabb}


resetToNextPoint

int resetToNextPoint()
. \begin{tabb}
 Increases the current point index by 1 and returns its new value.
 ...
 ...l be raised only if we
 ask for a new coordinate or point later on.
 \end{tabb}
index of the new current point


getCurPointIndex

int getCurPointIndex()
. \begin{tabb}
 Returns the index $i$\ of the current point.
 This can be useful, e.g., for caching point sets.
 \end{tabb}
index of the current point


hasNextPoint

boolean hasNextPoint()
. \begin{tabb}
 Returns \texttt{true} if there is a next point.
 This can be useful for testing if points are still available.
 \end{tabb}
true if a next point is available from the iterated point set


nextPoint

int nextPoint(double[] p,
              int fromDim,
              int d)
. \begin{tabb}
 Returns in \texttt{p} the next \texttt{d} coordinates of the \emph...
 ... allowing non-incremental point enumerations via Gray-code counters.
 \end{tabb}
parray to be filled with the coordinates, starting from array index 0 fromDimnumber of coordinates to be skipped dnumber of coordinates to return index of the new current point NoSuchElementExceptionif there are not enough coordinates available in the current point for filling p


nextPoint

int nextPoint(double[] p,
              int d)
. \begin{tabb}
 Same as \method{nextPoint (p, 0, d)}{}.
 \end{tabb}


SSJ
V. labo.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.