org.pokersource.util

Class NestedLoopSampling

Implemented Interfaces:
Enumeration

public class NestedLoopSampling
extends java.lang.Object
implements Enumeration

Like NestedLoopEnumeration, but rather than visiting every entry in turn, randomly samples with replacement.
Author:
Michael Maurer <mjmaurer@yahoo.com>
See Also:
NestedLoopEnumeration

Constructor Summary

NestedLoopSampling(int[] limits)
NestedLoopSampling(int[] limits, int nsamples)
Initializes a nested loop sampler with limits.length dimensions.

Method Summary

boolean
hasMoreElements()
Object
nextElement()
Return an integer array sampling the next loop indices for each dimension.

Constructor Details

NestedLoopSampling

public NestedLoopSampling(int[] limits)

NestedLoopSampling

public NestedLoopSampling(int[] limits,
                          int nsamples)
Initializes a nested loop sampler with limits.length dimensions.
Parameters:
limits - limits[i] is the upper limit of the ith nested loop (the loop runs from 0 to limits[i]-1 inclusive)
nsamples - the number of samples to generate before hasMoreElements() returns false

Method Details

hasMoreElements

public boolean hasMoreElements()

nextElement

public Object nextElement()
Return an integer array sampling the next loop indices for each dimension.
Returns:
An object of int[] type; the ith value is the loop variable for the ith nested loop.

PokerSource Home Page - Learn how you can contribute!