Interface  Description 

PrefixMap<S extends CharSequence> 
A map from prefixes to string intervals (and possibly vice versa).

StringMap<S extends CharSequence> 
A map from strings to numbers (and possibly vice versa).

Class  Description 

AbstractPrefixMap 
An abstract implementation of a prefix map.

BloomFilter<T> 
A Bloom filter.

ByteBufferLongBigList 
A bridge between byte buffers and long big lists.

CircularCharArrayBuffer 
A circular char buffer that can be used to implement a sliding
window over a text.

FrontCodedStringList 
Compact storage of strings using frontcoding compression (a.k.a. compression by prefix omission).

HyperLogLogCounterArray 
An array of approximate sets each represented using a HyperLogLog counter.

ImmutableBinaryTrie<T> 
An immutable implementation of binary tries.

ImmutableBinaryTrie.Node 
A node in the trie.

ImmutableExternalPrefixMap 
An immutable prefix map mostly stored in external memory.

Interval 
An interval of integers.

Intervals 
A class providing static methods and objects that do useful things with intervals.

KahanSummation 
Kahan's
summation algorithm encapsulated in an object.

LiterallySignedStringMap 
A string map based on a function signed using the original list of strings.

LongInterval 
An interval of longs.

LongIntervals 
A class providing static methods and objects that do useful things with intervals.

PermutedFrontCodedStringList 
A
FrontCodedStringList whose indices are permuted. 
Properties 
An extension of
PropertiesConfiguration
providing setters for primitive types, a simpler way to save preferences
and transparent handling of Enum lowercased keys. 
SemiExternalGammaList 
Provides semiexternal random access to a list of γencoded integers.

ShiftAddXorSignedStringMap  Deprecated
There are much better and faster hash functions.

SplitMix64Random 
A fast, highquality, nonsplittable version of the SplitMix
pseudorandom number generator used by
SplittableRandom . 
SplitMix64RandomGenerator 
A fast, highquality, nonsplittable version of the SplitMix
pseudorandom number generator used by
SplittableRandom . 
StringMaps 
A class providing static methods and objects that do useful things with string maps
and prefix maps.

StringMaps.SynchronizedPrefixMap<S extends CharSequence>  
StringMaps.SynchronizedStringMap<S extends CharSequence>  
TernaryIntervalSearchTree 
Ternary interval search trees.

TextPattern 
QuickSearch matching against a constant string.

XoRoShiRo128PlusRandom 
A fast, highquality pseudorandom number generator that
returns the sum of consecutive outputs of a handcrafted linear generator with 128 bits of state.

XoRoShiRo128PlusRandomGenerator 
A fast, highquality pseudorandom number generator that
returns the sum of consecutive outputs of a handcrafted linear generator with 128 bits of state.

XorShift1024StarPhiRandom 
A fast, highquality pseudorandom number generator that
combines a longperiod instance of George Marsaglia's Xorshift generators (described in “Xorshift RNGs”, Journal of
Statistical Software, 8:1−6, 2003) with a multiplication.

XorShift1024StarPhiRandomGenerator 
A fast, highquality pseudorandom number generator that
combines a longperiod instance of George Marsaglia's Xorshift generators (described in “Xorshift RNGs”, Journal of
Statistical Software, 8:1−6, 2003) with a multiplication.

XorShift1024StarRandom  Deprecated
Please use
XorShift1024StarPhiRandom instead. 
XorShift1024StarRandomGenerator  Deprecated
Please use
XorShift1024StarPhiRandomGenerator instead. 
XorShift128PlusRandom  Deprecated
Please use
XoRoShiRo128PlusRandom instead. 
XorShift128PlusRandomGenerator  Deprecated
Please use
XoRoShiRo128PlusRandomGenerator instead. 
XorShift64StarRandom  Deprecated
Use
SplitMix64Random instead. 
XorShift64StarRandomGenerator  Deprecated
Use
SplitMix64RandomGenerator instead. 
Miscellaneaous utility classes.
nextInt()
,
nextInt(int)
and nextLong(int)
of
XoRoShiRo128PlusRandomGenerator
/XoRoShiRo128PlusRandom
implement a different logic that prefers the high bits. The results will be thus different
from previous versions.
We provide a number of fast, highquality PRNGs with different features.
xoroshiro128+
is a fast, highquality generator.
It has strong statistical properties and it is the fastest generator we provide. Its period (2^{128} − 1) is sufficient
for any application with a reasonable amount of parallelism. It is our suggestion for an allpurpose generator. It is the
default generator in Erlang.
SplitMix64
is a fast, highquality generator, but it has a relatively short period (2^{64}) so it should
not be used to generate very long sequences (the rule of thumb to have a period greater than the square of the length of the sequence you want to generate).
It is a nonsplittable version of SplittableRandom
,
and thus conceptually identical to ThreadLocalRandom
(note that Java 7's version
was identical to Random
, instead). We use it to initialize the state of all other generators starting from a 64bit seed.
xorshift1024*φ
is fast, highquality
and provides a long period (2^{1024} − 1) for massive parallel computations.
, xoroshiro128+
and
xorshift128+
provide
jump functions which make it possible to generate long nonoverlapping sequences,
and split functions in the spirit of xorshift1024*φ
SplittableRandom
.
A table summarizing timings is provided below. The timings were measured on an
Intel® Core™ i77700 CPU @ 3.60GHz (Kaby Lake).
Note that we test several different method parameters to highlight
the different strategies used to generate numbers in a range, as the rejectionbased algorithm used by all generators
can be based on integer or long inputs, and the results are quite different. For example, on modern, 64bit CPUs Java's
strategy of applying rejection to 32bit integers does not pay off (see the timings for nextInt(2^{30} + 1)
).
The timings are very different from previous versions, but they
should be more reliable, as they are now obtained by means of
JMH microbenchmarks. The JMH timings were decreased by 1ns, as
using the lowlevel perfasm
profiler the JMH overhead was estimated at ≈1ns per call.
Random
 ThreadLocalRandom
 SplittableRandom
 SplitMix64



 

nextInt()  7.387  1.490  1.329  1.325  1.521  1.459  2.235 
nextLong()  15.772  1.512  1.389  1.450  1.424  1.437  2.088 
nextDouble()  16.052  2.140  2.400  2.396  2.283  2.012  3.012 
nextInt(100000)  7.388  2.322  2.731  2.878  2.303  2.475  3.525 
nextInt(2^{29}+2^{28})  11.514  7.303  7.400  3.167  2.432  2.611  3.728 
nextInt(2^{30})  7.398  1.587  1.452  1.526  1.526  1.807  2.238 
nextInt(2^{30} + 1)  20.988  14.583  15.022  2.950  2.306  2.601  3.61 
nextInt(2^{30} + 2^{29})  11.503  7.413  7.387  3.148  2.438  2.617  3.727 
nextLong(1000000000000)  2.551  3.006  2.989  2.382  2.618  3.621  
nextLong(2^{62} + 1)  15.100  15.414  15.540  12.649  13.821  16.805 
The quality of all generators we provide is very high: for instance, they perform better than WELL1024a
or MT19937
(AKA the Mersenne Twister) in the TestU01 BigCrush test suite.
More details can be found on the xoroshiro+
/xorshift*
/xorshift+
generators and the PRNG shootout page.
For each generator, we provide a version that extends Random
, overriding (as usual) the next(int)
method. Nonetheless,
since the generators are all inherently 64bit also nextInt()
, nextFloat()
,
nextLong()
, nextDouble()
, nextBoolean()
and nextBytes(byte[])
have been overridden for speed (preserving, of course, Random
's semantics).
Warning: Before version 2.4.1, nextDouble()
and nextFloat()
were using a multiplicationfree conversion that was significantly faster. However, the technique
can generate only dyadic rationals of the form k / 2^{−52}, instead of the standard k / 2^{−53},
so you were generating half of values
(essentially, the lowest bit of the mantissa would always be zero: this can be fixed with a test, but then the technique is not so fast
anymore). Now the code performs the standard multiplication conversion: the only difference is that in half of the output there might
be a last binary digit set to one. The old multiplicationfree implementation is available under the name nextDoubleFast()
.
If you do not need an instance of Random
, or if you need a RandomGenerator
to use
with Commons Math, there is for each generator a corresponding RandomGenerator
implementation, which indeed we suggest to use in general if you do not need a generator implementing Random
.