Class RoaringIntPacking

java.lang.Object
org.roaringbitmap.longlong.RoaringIntPacking

class RoaringIntPacking extends Object
Used to hold the logic packing 2 integers in a long, and separating a long in two integers. It is useful in Roaring64NavigableMap 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 Details

    • TWO_64

      private static final BigInteger TWO_64
      the constant 2^64
  • Constructor Details

    • RoaringIntPacking

      RoaringIntPacking()
  • Method Details

    • 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 long
      low - an integer representing the lowest order bits of the output long
      Returns:
      a long packing together the integers as computed by high(long) and low(long)
    • highestHigh

      public static int highestHigh(boolean signedLongs)
      Parameters:
      signedLongs - true if long put in a Roaring64NavigableMap 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 Comparator<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 two int values numerically treating the values as unsigned.
      Parameters:
      x - the first int to compare
      y - the second int to compare
      Returns:
      the value 0 if x == y; a value less than 0 if x < y as unsigned values; and a value greater than 0 if x > y as unsigned values
      Since:
      1.8
    • toUnsignedString

      static String toUnsignedString(long l)
      JDK8 Long.toUnsignedString was too complex to backport. Go for a slow version relying on BigInteger