Package org.roaringbitmap.longlong
Class LongUtils
- java.lang.Object
-
- org.roaringbitmap.longlong.LongUtils
-
public class LongUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static long
MAX_UNSIGNED_INT
-
Constructor Summary
Constructors Constructor Description LongUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
fromBDBytes(byte[] work)
get the long from the big endian representation bytesstatic byte[]
highPart(long num)
get the high 48 bit parts of the input datastatic byte[]
highPartInPlace(long num, byte[] high48)
set the high 48 bit parts of the input number into the given byte arraystatic long
initWithFirst4Byte(int v)
initialize a long value with the given fist 32 bitstatic boolean
isMaxHigh(long key)
checks if given high48 is the maximum possible one (e.g.static long
leftShiftHighPart(long num)
shift the long by left the container size amount so we use the value after have done our stepsstatic char
lowPart(long num)
get the low 16 bit parts of the input datastatic int
maxLowBitAsInteger()
static long
rightShiftHighPart(long num)
shift the long right by the container size amount so we can loop across containers by +1 stepsstatic byte[]
toBDBytes(long v)
to big endian bytes representationstatic long
toLong(byte[] high)
Reconstruct the long data.static long
toLong(byte[] high, char low)
reconstruct the long datastatic long
toLong(long high, char low)
-
-
-
Method Detail
-
highPart
public static byte[] highPart(long num)
get the high 48 bit parts of the input data- Parameters:
num
- the long number- Returns:
- the high 48 bit
-
lowPart
public static char lowPart(long num)
get the low 16 bit parts of the input data- Parameters:
num
- the long number- Returns:
- the low 16 bit
-
toLong
public static long toLong(byte[] high, char low)
reconstruct the long data- Parameters:
high
- the high 48 bitlow
- the low 16 bit- Returns:
- the long data
-
toLong
public static long toLong(byte[] high)
Reconstruct the long data.- Parameters:
high
- the high 48 bit- Returns:
- the long data
-
toLong
public static long toLong(long high, char low)
-
toBDBytes
public static byte[] toBDBytes(long v)
to big endian bytes representation- Parameters:
v
- a long value- Returns:
- the input long value's big endian byte array representation
-
fromBDBytes
public static long fromBDBytes(byte[] work)
get the long from the big endian representation bytes- Parameters:
work
- the byte array- Returns:
- the long data
-
initWithFirst4Byte
public static long initWithFirst4Byte(int v)
initialize a long value with the given fist 32 bit- Parameters:
v
- first 32 bit value- Returns:
- a long value
-
rightShiftHighPart
public static long rightShiftHighPart(long num)
shift the long right by the container size amount so we can loop across containers by +1 steps- Parameters:
num
- long being treated as unsigned long- Returns:
- value shifted out of value space into container high part
-
leftShiftHighPart
public static long leftShiftHighPart(long num)
shift the long by left the container size amount so we use the value after have done our steps- Parameters:
num
- uint48 to be shift back into uint64- Returns:
- value shifted out of container high part back into value space
-
maxLowBitAsInteger
public static int maxLowBitAsInteger()
-
highPartInPlace
public static byte[] highPartInPlace(long num, byte[] high48)
set the high 48 bit parts of the input number into the given byte array- Parameters:
num
- the long numberhigh48
- the byte array- Returns:
- the high 48 bit
-
isMaxHigh
public static boolean isMaxHigh(long key)
checks if given high48 is the maximum possible one (e.g. it is the case for -1L, which is the maximum unsigned long)- Parameters:
key
- long- Returns:
- true if this the maximum high part
-
-