-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longprivate static final longprivate static final longprivate static final longprivate static final longprivate static final longprivate static final longstatic final ByteOrderNative byte order.private static final longprivate static final longprivate static final longprivate static final longprivate static final longstatic final VarHandleDeprecated.Better use little endian unless it is needed for backwards compatibility.static final VarHandleDeprecated.Better use little endian unless it is needed for backwards compatibility.static final VarHandleDeprecated.Better use little endian unless it is needed for backwards compatibility.static final VarHandleDeprecated.Better use little endian unless it is needed for backwards compatibility.static final VarHandleDeprecated.Better use little endian unless it is needed for backwards compatibility.static final VarHandleAVarHandleto read/write little endiandoublefrom a byte array.static final VarHandleAVarHandleto read/write little endianfloatfrom a byte array.static final VarHandleAVarHandleto read/write little endianintfrom a byte array.static final VarHandleAVarHandleto read/write little endianlongfrom a byte array.static final VarHandleAVarHandleto read/write little endianshortfrom/to a byte array.static final VarHandleAVarHandleto read/write native endiandoublefrom a byte array.static final VarHandleAVarHandleto read/write native endianfloatfrom a byte array.static final VarHandleAVarHandleto read/write native endianintfrom a byte array.static final VarHandleAVarHandleto read/write native endianlongfrom a byte array.static final VarHandleAVarHandleto read/write native endianshortfrom/to a byte array. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longdeinterleave(long b) Extract just the even-bits value as a long from the bit-interleaved valuestatic longflipFlop(long b) flip flops odd with even bitsprivate static ByteOrderstatic longinterleave(int even, int odd) Interleaves the first 32 bits of each long valuestatic intnextHighestPowerOfTwo(int v) returns the next highest power of two, or the current value if it's already a power of two or zerostatic longnextHighestPowerOfTwo(long v) returns the next highest power of two, or the current value if it's already a power of two or zerostatic intzigZagDecode(int i) Decode an int previously encoded withzigZagEncode(int).static longzigZagDecode(long l) Decode a long previously encoded withzigZagEncode(long).static intzigZagEncode(int i) Same aszigZagEncode(long)but on integers.static longzigZagEncode(long l) Zig-zag encode the provided long.
-
Field Details
-
NATIVE_BYTE_ORDER
Native byte order.Warning: This constant is
ByteOrder.nativeOrder()only in production environments, during testing we randomize it. If you need to communicate with native APIs (e.g., Java's Panama API), useByteOrder.nativeOrder(). -
VH_LE_SHORT
AVarHandleto read/write little endianshortfrom/to a byte array. Shape:short vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, short val) -
VH_LE_INT
AVarHandleto read/write little endianintfrom a byte array. Shape:int vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, int val) -
VH_LE_LONG
AVarHandleto read/write little endianlongfrom a byte array. Shape:long vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, long val) -
VH_LE_FLOAT
AVarHandleto read/write little endianfloatfrom a byte array. Shape:float vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, float val) -
VH_LE_DOUBLE
AVarHandleto read/write little endiandoublefrom a byte array. Shape:double vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, double val) -
VH_NATIVE_SHORT
AVarHandleto read/write native endianshortfrom/to a byte array. Shape:short vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, short val)Warning: This handle uses default order only in production environments, during testing we randomize it. If you need to communicate with native APIs (e.g., Java's Panama API), use
ByteOrder.nativeOrder(). -
VH_NATIVE_INT
AVarHandleto read/write native endianintfrom a byte array. Shape:int vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, int val)Warning: This handle uses default order only in production environments, during testing we randomize it. If you need to communicate with native APIs (e.g., Java's Panama API), use
ByteOrder.nativeOrder(). -
VH_NATIVE_LONG
AVarHandleto read/write native endianlongfrom a byte array. Shape:long vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, long val)Warning: This handle uses default order only in production environments, during testing we randomize it. If you need to communicate with native APIs (e.g., Java's Panama API), use
ByteOrder.nativeOrder(). -
VH_NATIVE_FLOAT
AVarHandleto read/write native endianfloatfrom a byte array. Shape:float vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, float val)Warning: This handle uses default order only in production environments, during testing we randomize it. If you need to communicate with native APIs (e.g., Java's Panama API), use
ByteOrder.nativeOrder(). -
VH_NATIVE_DOUBLE
AVarHandleto read/write native endiandoublefrom a byte array. Shape:double vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, double val)Warning: This handle uses default order only in production environments, during testing we randomize it. If you need to communicate with native APIs (e.g., Java's Panama API), use
ByteOrder.nativeOrder(). -
VH_BE_SHORT
Deprecated.Better use little endian unless it is needed for backwards compatibility.AVarHandleto read/write big endianshortfrom a byte array. Shape:short vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, short val) -
VH_BE_INT
Deprecated.Better use little endian unless it is needed for backwards compatibility.AVarHandleto read/write big endianintfrom a byte array. Shape:int vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, int val) -
VH_BE_LONG
Deprecated.Better use little endian unless it is needed for backwards compatibility.AVarHandleto read/write big endianlongfrom a byte array. Shape:long vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, long val) -
VH_BE_FLOAT
Deprecated.Better use little endian unless it is needed for backwards compatibility.AVarHandleto read/write big endianfloatfrom a byte array. Shape:float vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, float val) -
VH_BE_DOUBLE
Deprecated.Better use little endian unless it is needed for backwards compatibility.AVarHandleto read/write big endiandoublefrom a byte array. Shape:double vh.get(byte[] arr, int ofs)andvoid vh.set(byte[] arr, int ofs, double val) -
MAGIC0
private static final long MAGIC0- See Also:
-
MAGIC1
private static final long MAGIC1- See Also:
-
MAGIC2
private static final long MAGIC2- See Also:
-
MAGIC3
private static final long MAGIC3- See Also:
-
MAGIC4
private static final long MAGIC4- See Also:
-
MAGIC5
private static final long MAGIC5- See Also:
-
MAGIC6
private static final long MAGIC6- See Also:
-
SHIFT0
private static final long SHIFT0- See Also:
-
SHIFT1
private static final long SHIFT1- See Also:
-
SHIFT2
private static final long SHIFT2- See Also:
-
SHIFT3
private static final long SHIFT3- See Also:
-
SHIFT4
private static final long SHIFT4- See Also:
-
-
Constructor Details
-
BitUtil
private BitUtil()
-
-
Method Details
-
getNativeByteOrder
-
nextHighestPowerOfTwo
public static int nextHighestPowerOfTwo(int v) returns the next highest power of two, or the current value if it's already a power of two or zero -
nextHighestPowerOfTwo
public static long nextHighestPowerOfTwo(long v) returns the next highest power of two, or the current value if it's already a power of two or zero -
interleave
public static long interleave(int even, int odd) Interleaves the first 32 bits of each long valueAdapted from: http://graphics.stanford.edu/~seander/bithacks.html#InterleaveBMN
-
deinterleave
public static long deinterleave(long b) Extract just the even-bits value as a long from the bit-interleaved value -
flipFlop
public static long flipFlop(long b) flip flops odd with even bits -
zigZagEncode
public static int zigZagEncode(int i) Same aszigZagEncode(long)but on integers. -
zigZagEncode
public static long zigZagEncode(long l) Zig-zag encode the provided long. Assuming the input is a signed long whose absolute value can be stored onnbits, the returned value will be an unsigned long that can be stored onn+1bits. -
zigZagDecode
public static int zigZagDecode(int i) Decode an int previously encoded withzigZagEncode(int). -
zigZagDecode
public static long zigZagDecode(long l) Decode a long previously encoded withzigZagEncode(long).
-