com.h3c.util

## Class DistributedIndexGenerator

- java.lang.Object
- - com.h3c.util.DistributedIndexGenerator

-     public class DistributedIndexGenerator
      extends Object

  Implements iterators that generate indices randomly according to a specified distribution. For example:

       DistributedIndexGenerator gen = new DistributedIndexGenerator(30, 40);

  will create iterators that produce values from the set {0, 1, 2} randomly, where the probabilities of occurrence are 30%, 40%, and 30% respectively.

       Iterator<Integer> it = gen.iterator(10);

  returns an iterator that will generate 10 such random values.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DistributedIndexGenerator(int... percentages)` Constructs a generator that uses the specified distribution.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Iterator<Integer>` | `iterator(int count)` Returns an iterator which will return the specified number of random indices drawn from the distribution configured for this generator.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### DistributedIndexGenerator

          public DistributedIndexGenerator(int... percentages)

      Constructs a generator that uses the specified distribution. At least one percentage must be specified, and the sum of all percentages specified must be less than 100.
      Parameters:
        `percentages` - the required percentage probabilities for indices 0, 1, ...

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### iterator

          public Iterator<Integer> iterator(int count)

      Returns an iterator which will return the specified number of random indices drawn from the distribution configured for this generator.
      Parameters:
        `count` - the number of random indices to return
      Returns:
        an iterator

Copyright © 2014. All Rights Reserved.