Package org.roaringbitmap.longlong
Class RoaringIntPacking
- java.lang.Object
-
- org.roaringbitmap.longlong.RoaringIntPacking
-
class RoaringIntPacking extends java.lang.Object
Used to hold the logic packing 2 integers in a long, and separating a long in two integers. It is useful inRoaring64NavigableMap
as the implementation split the input long in two integers, one used as key of a NavigableMap while the other is added in a Bitmap
-
-
Field Summary
Fields Modifier and Type Field Description private static java.math.BigInteger
TWO_64
the constant 2^64
-
Constructor Summary
Constructors Constructor Description RoaringIntPacking()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
compareUnsigned(int x, int y)
Compares twoint
values numerically treating the values as unsigned.static int
high(long id)
static int
highestHigh(boolean signedLongs)
static int
low(long id)
static long
pack(int high, int low)
(package private) static java.lang.String
toUnsignedString(long l)
JDK8 Long.toUnsignedString was too complex to backport.static java.util.Comparator<java.lang.Integer>
unsignedComparator()
-
-
-
Method Detail
-
high
public static int high(long id)
- Parameters:
id
- any long, positive or negative- Returns:
- an int holding the 32 highest order bits of information of the input long
-
low
public static int low(long id)
- Parameters:
id
- any long, positive or negative- Returns:
- an int holding the 32 lowest order bits of information of the input long
-
pack
public static long pack(int high, int low)
- Parameters:
high
- an integer representing the highest order bits of the output longlow
- an integer representing the lowest order bits of the output long- Returns:
- a long packing together the integers as computed by
high(long)
andlow(long)
-
highestHigh
public static int highestHigh(boolean signedLongs)
- Parameters:
signedLongs
- true if long put in aRoaring64NavigableMap
should be considered as signed long.- Returns:
- the int representing the highest value which can be set as high value in a
Roaring64NavigableMap
-
unsignedComparator
public static java.util.Comparator<java.lang.Integer> unsignedComparator()
- Returns:
- A comparator for unsigned longs: a negative long is a long greater than Long.MAX_VALUE
-
compareUnsigned
public static int compareUnsigned(int x, int y)
Compares twoint
values numerically treating the values as unsigned.- Parameters:
x
- the firstint
to comparey
- the secondint
to compare- Returns:
- the value
0
ifx == y
; a value less than0
ifx < y
as unsigned values; and a value greater than0
ifx > y
as unsigned values - Since:
- 1.8
-
toUnsignedString
static java.lang.String toUnsignedString(long l)
JDK8 Long.toUnsignedString was too complex to backport. Go for a slow version relying on BigInteger
-
-