Uploaded image for project: 'Commons RNG'
  1. Commons RNG
  2. RNG-116

RandomSource to expose supported functionality and seed size

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Implemented
    • 1.3
    • 1.3
    • simple
    • None

    Description

      Interface support

      The RandomSource can be used to created instances that may implement JumpableUniformRandomProvider. This requires casting the returned value from the create method. Add methods to expose the interfaces supported by the provider without instantiation.

      public boolean isJumpable();
      public boolean isLongJumpable();
      

      This will allow:

      RandomSource source = ...;
      if (source.isJumpable()) {
          JumpableUniformRandomProvider rng =
              (JumpableUniformRandomProvider) RandomSource.create(source);
      }
      

      Seed size

      The internal components used to build the generators by RandomSource know the size of the seed required for the constructor. This can be exposed in a method:

      public int getSeedByteSize();
      

      This will allow:

      RandomSource source = ...;
      SecureRandom sr = new SecureRandom();
      UniformRandomProvider rng = RandomSource.create(source,
          sr.generateSeed(source.getSeedByteSize()));
      

      Attachments

        Issue Links

          Activity

            People

              aherbert Alex Herbert
              aherbert Alex Herbert
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m