org.apache.hadoop.mapred.gridmix
Class RandomAlgorithms.Selector

java.lang.Object
  extended by org.apache.hadoop.mapred.gridmix.RandomAlgorithms.Selector
Enclosing class:
RandomAlgorithms

public static class RandomAlgorithms.Selector
extends Object

Iteratively pick random numbers from pool 0..n-1. Each number can only be picked once.


Constructor Summary
RandomAlgorithms.Selector(int n, double selPcnt, Random rand)
          Constructor.
 
Method Summary
 int getPoolSize()
          Get the remaining random number pool size.
 int next()
          Select the next random number.
 void reset()
          Reset the selector for reuse usage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomAlgorithms.Selector

public RandomAlgorithms.Selector(int n,
                                 double selPcnt,
                                 Random rand)
Constructor.

Parameters:
n - The pool of integers: 0..n-1.
selPcnt - Percentage of selected numbers. This is just a hint for internal memory optimization.
rand - Random number generator.
Method Detail

next

public int next()
Select the next random number.

Returns:
Random number selected. Or -1 if the remaining pool is empty.

getPoolSize

public int getPoolSize()
Get the remaining random number pool size.


reset

public void reset()
Reset the selector for reuse usage.



Copyright © 2009 The Apache Software Foundation