Enum Byte16ArrayArithmetic
- java.lang.Object
-
- java.lang.Enum<Byte16ArrayArithmetic>
-
- io.github.pr0methean.betterrandom.util.Byte16ArrayArithmetic
-
- All Implemented Interfaces:
Serializable
,Comparable<Byte16ArrayArithmetic>
public enum Byte16ArrayArithmetic extends Enum<Byte16ArrayArithmetic>
Collection of arithmetic methods that treatbyte[16]
arrays as 128-bit unsigned integers.
-
-
Field Summary
Fields Modifier and Type Field Description static byte[]
ONE
The 128-bit value 1.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addInto(byte[] counter, byte[] delta)
counter += delta
.static void
addInto(byte[] counter, long delta)
counter += delta
static void
multiplyInto(byte[] counter, byte[] mult)
counter *= multiplier
static void
multiplyIntoAndAddInto(byte[] counter, byte[] mult, byte[] add)
counter *= mult; counter += add
static void
rotateRight(byte[] shifted, int bits)
shifted = (shifted >>> bits) | shifted << (128 - bits)
static long
rotateRightLeast64(byte[] shifted, int bits)
Returns the lower 64 bits of the result when the input is rotated.static long
shiftedLeast(int bits, long oldMost, long oldLeast)
Returns the lower 64 bits of(oldMost << 64LL + oldLeast) >>> bits
.static long
shiftedMost(int bits, long oldMost, long oldLeast)
Returns the upper 64 bits of(oldMost << 64LL + oldLeast) >>> bits
.static void
unsignedShiftRight(byte[] shifted, int bits)
shifted >>>= bits
From this source.static long
unsignedShiftRightLeast64(byte[] shifted, int bits)
Returns the lower 64 bits of the shifted input.static Byte16ArrayArithmetic
valueOf(String name)
Returns the enum constant of this type with the specified name.static Byte16ArrayArithmetic[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Method Detail
-
values
public static Byte16ArrayArithmetic[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Byte16ArrayArithmetic c : Byte16ArrayArithmetic.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Byte16ArrayArithmetic valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
addInto
public static void addInto(byte[] counter, long delta)
counter += delta
- Parameters:
counter
- the variable-sized input and the resultdelta
- the long-sized input
-
addInto
public static void addInto(byte[] counter, byte[] delta)
counter += delta
. Inputs must be the same length.- Parameters:
counter
- the first input and the resultdelta
- the second input
-
multiplyInto
public static void multiplyInto(byte[] counter, byte[] mult)
counter *= multiplier
- Parameters:
counter
- the first input and the resultmult
- the second input
-
multiplyIntoAndAddInto
public static void multiplyIntoAndAddInto(byte[] counter, byte[] mult, byte[] add)
counter *= mult; counter += add
- Parameters:
counter
- the first input and the resultmult
- the input to multiply byadd
- the input to add after multiplying
-
unsignedShiftRight
public static void unsignedShiftRight(byte[] shifted, int bits)
shifted >>>= bits
From this source.- Parameters:
shifted
- the array input and the resultbits
- how many bits to shift by
-
unsignedShiftRightLeast64
public static long unsignedShiftRightLeast64(byte[] shifted, int bits)
Returns the lower 64 bits of the shifted input. From this source.- Parameters:
shifted
- the array input and the resultbits
- how many bits to shift by- Returns:
(long)(shifted >>> bits)
-
shiftedMost
public static long shiftedMost(int bits, long oldMost, long oldLeast)
Returns the upper 64 bits of(oldMost << 64LL + oldLeast) >>> bits
.- Parameters:
bits
- how many bits to shift byoldMost
- upper 64 bits of inputoldLeast
- lower 64 bits of input- Returns:
- the upper 64 bits of
(oldMost << 64LL + oldLeast) >>> bits
-
shiftedLeast
public static long shiftedLeast(int bits, long oldMost, long oldLeast)
Returns the lower 64 bits of(oldMost << 64LL + oldLeast) >>> bits
.- Parameters:
bits
- how many bits to shift byoldMost
- upper 64 bits of inputoldLeast
- lower 64 bits of input- Returns:
- the lower 64 bits of
(oldMost << 64LL + oldLeast) >>> bits
-
rotateRight
public static void rotateRight(byte[] shifted, int bits)
shifted = (shifted >>> bits) | shifted << (128 - bits)
- Parameters:
shifted
- the array input and the resultbits
- how many bits to shift by
-
rotateRightLeast64
public static long rotateRightLeast64(byte[] shifted, int bits)
Returns the lower 64 bits of the result when the input is rotated.- Parameters:
shifted
- the array input and the resultbits
- how many bits to shift by- Returns:
(long) ((shifted >>> bits) | shifted << (128 - bits))
-
-