sam.toolkit
Class Random.IntegerSetRandomizer

java.lang.Object
  |
  +--sam.toolkit.Random.IntegerSetRandomizer
All Implemented Interfaces:
java.util.Enumeration
Enclosing class:
Random

public static class Random.IntegerSetRandomizer
extends java.lang.Object
implements java.util.Enumeration

Class for randomizing over fixed integer sets. This is a randomizer that randomly chooses a permutation on a set of integers. Note that all n! permutations on n integers are equi-probable. This class implements such a randomly chosen permutation as a standard Enumeration on those allows integers.


Constructor Summary
Random.IntegerSetRandomizer(int length)
          Builds a new randomly choosen permutation on a range of integers.
Random.IntegerSetRandomizer(int[] credits)
          Builds a new randomly choosen permutation on a range of weighted integers.
 
Method Summary
 boolean hasMoreElements()
          Wether this enumeration has more elements to enumerate.
 int next()
          Gets the next integer to enumerate
 java.lang.Object nextElement()
          Gets the next element to enumerate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Random.IntegerSetRandomizer

public Random.IntegerSetRandomizer(int length)
Builds a new randomly choosen permutation on a range of integers.

Parameters:
length - the largest integer: the integer range thus is [0 , length-1].

Random.IntegerSetRandomizer

public Random.IntegerSetRandomizer(int[] credits)
Builds a new randomly choosen permutation on a range of weighted integers.

Method Detail

hasMoreElements

public boolean hasMoreElements()
Wether this enumeration has more elements to enumerate.

Specified by:
hasMoreElements in interface java.util.Enumeration

nextElement

public java.lang.Object nextElement()
                             throws java.util.NoSuchElementException
Gets the next element to enumerate

Specified by:
nextElement in interface java.util.Enumeration
Returns:
an instance of Integer containing the next integer
Throws:
java.util.NoSuchElementException - if no more such integer is to be enumerated

next

public int next()
         throws java.util.NoSuchElementException
Gets the next integer to enumerate

Throws:
java.util.NoSuchElementException - if no more such integer is to be enumerated