@Reference(authors = "D. Lemire", //
      title = "Fast random shuffling", //
      booktitle = "Daniel Lemire's blog", //
      url = "http://lemire.me/blog/2016/06/30/fast-random-shuffling/", //
      bibkey = "blog/Lemire16")
  @Override
  public int nextInt(int n) {
    if(n <= 0) {
      throw new IllegalArgumentException(BADBOUND);
    }
    seed = (seed * multiplier + addend) & mask;
    return (int) (((seed >>> 16) * n) >>> 32);
  }
@ Reference ( authors = "D. Lemire" , title = "Fast random shuffling" , booktitle = "Daniel Lemire's blog" , url = "http://lemire.me/blog/2016/06/30/fast-random-shuffling/" , bibkey = "blog/Lemire16" ) @ Override public int nextInt ( int n ) { if ( n <= 0 ) { throw new IllegalArgumentException ( BADBOUND ) ; } seed = ( seed * multiplier + addend ) & mask ; return ( int ) ( ( ( seed > > > 16 ) * n ) > > > 32 ) ; }
Returns a pseudorandom, uniformly distributed {@code int} value between 0
(inclusive) and the specified value (exclusive), drawn from this random
number generator's sequence. The general contract of {@code nextInt} is
that one {@code int} value in the specified range is pseudorandomly
generated and returned. All {@code n} possible {@code int} values are
produced with (approximately) equal probability.
<p>
In contrast to the Java version, we use an approach that tries to avoid
divisions for performance. We will have a slightly worse distribution in
this fast version (see the XorShift generators for higher quality with
rejection sampling) discussed in:
<p>
D. Lemire<br>
Fast random shuffling<br>
http://lemire.me/blog/2016/06/30/fast-random-shuffling/