A class providing static methods and objects that do useful things with
type-specific arrays.
In particular, the
forceCapacity(),
ensureCapacity(),
grow(),
trim() and
setLength() methods allow to
handle arrays much like array lists. This can be very useful when efficiency
(or syntactic simplicity) reasons make array lists unsuitable.
Note that
it.unimi.dsi.fastutil.io.BinIO and
it.unimi.dsi.fastutil.io.TextIO contain several methods make it
possible to load and save arrays of primitive types as sequences of elements
in
java.io.DataInput format (i.e., not as objects) or as sequences of
lines of text.
Sorting
There are several sorting methods available. The main theme is that of
letting you choose the sorting algorithm you prefer (i.e., trading stability
of mergesort for no memory allocation in quicksort). Several algorithms
provide a parallel version, that will use the
Runtime#availableProcessors(). Some
algorithms also provide an explicit indirect sorting facility, which
makes it possible to sort an array using the values in another array as
comparator.
All comparison-based algorithm have an implementation based on a
type-specific comparator.
As a general rule, sequential radix sort is significantly faster than
quicksort or mergesort, in particular on random-looking data. In the parallel
case, up to a few cores parallel radix sort is still the fastest, but at some
point quicksort exploits parallelism better.
If you are fine with not knowing exactly which algorithm will be run (in
particular, not knowing exactly whether a support array will be allocated),
the dual-pivot parallel sorts in
java.util.Arrays are about 50%
faster than the classical single-pivot implementation used here.
In any case, if sorting time is important I suggest that you benchmark your
sorting load with your data distribution and on your architecture.