Class PermutationGenerator


  • public class PermutationGenerator
    extends Object
    Utility class to generate uniformly distributed random permutations of integers in the range 0..size Permutation generation deterministically produces the same result if given the same seed value This class is used to implement enhanced request routing scheme as described in http://is.red.iplanet.com/failover/s1as7/IS62-SessionFailover.sxw
    • Constructor Detail

      • PermutationGenerator

        public PermutationGenerator​(String seed,
                                    int size)
        Constructor
        Parameters:
        seed - seed used by RNG
        size - permutation size
      • PermutationGenerator

        public PermutationGenerator​(long seed,
                                    int size)
        ConstructsPermutationGenerator
        Parameters:
        seed - seed used by RNG
        size - permutation size
    • Method Detail

      • itemAt

        public short itemAt​(int pos)
        Returns permutation element at a given position Throws
        Parameters:
        pos - permutation element position
        Returns:
        permutation element value
        Throws:
        IndexOutOfBoundsException - if index is less than 0 or greater than permutation size specified in constructor