**'edu.rit.util.RandomSubset'**Java class

edu.rit.util

## Class RandomSubset

- java.lang.Object
- edu.rit.util.RandomSubset

public class RandomSubsetextends Objectimplements Iterator<Integer>

Class RandomSubset provides an object that generates a random subset of a set of integers. The original set consists of the integers from 0 to*N*−1 inclusive. The subset consists of integers chosen at random without replacement from the original set; each member of the original set is equally likely to be chosen. Class RandomSubset is an Iterator that visits the elements of the original set in a random order; each`next()`method call returns another element of the subset.Calling the

`remove(i)`method one or more times removes the given integers from the original set. Those integers will not be chosen for the random subset.Class RandomSubset is layered on top of a pseudorandom number generator (PRNG), an instance of class Random. Each time the

`next()`method is called, one random number is consumed from the underlying PRNG.Class RandomSubset has two different implementations with different storage requirements. The implementation is specified with a constructor argument.

- The
*sparse*implementation requires less storage when the size of the random subset (the number of`next()`method calls) is a small fraction of the size of the original set (*N*). - The
*dense*implementation requires less storage when the size of the random subset is a large fraction of the size of the original set.

- The

**Warning:**You cannot see the full API documentation of this class since the access to the DatMelt documentation for third-party Java classes is denied. Guests can only view jhplot Java API. To view the complete description of this class and its methods, please request the full DataMelt membership.

If you are already a full member, please login to the DataMelt member area before visiting this documentation.