public class UFIntTool
UFInt is an abbreviation for Unsigned Fixed-width Integer.
This class converts between positive ints and 1-4 bytes that represent the int. All input ints
must be positive. Max values stored in N bytes are:
N=1: 2^8 => 256
N=2: 2^16 => 65,536
N=3: 2^24 => 16,777,216
N=4: 2^31 => 2,147,483,648 (Integer.MAX_VALUE)
This was created to get most of the memory savings of a variable length integer when encoding
an array of input integers, but to fix the number of bytes for each integer to the number needed
to store the maximum integer in the array. This enables a binary search to be performed on the
array of encoded integers.
PrefixTree nodes often store offsets into a block that can fit into 1 or 2 bytes. Note that if
the maximum value of an array of numbers needs 2 bytes, then it's likely that a majority of the
numbers will also require 2 bytes.
* no input validation for max performance
* no negatives