Class 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 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 Summary

      Fields 
      Modifier and Type Field Description
      private static java.math.BigInteger TWO_64
      the constant 2^64
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int compareUnsigned​(int x, int y)
      Compares two int 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()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TWO_64

        private static final java.math.BigInteger TWO_64
        the constant 2^64
    • Constructor Detail

      • RoaringIntPacking

        RoaringIntPacking()
    • 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 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 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 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 java.lang.String toUnsignedString​(long l)
        JDK8 Long.toUnsignedString was too complex to backport. Go for a slow version relying on BigInteger