Class IntegerUtil

java.lang.Object
org.roaringbitmap.longlong.IntegerUtil

public class IntegerUtil extends Object
  • Constructor Details

    • IntegerUtil

      public IntegerUtil()
  • Method Details

    • toBDBytes

      public static byte[] toBDBytes(int v)
      convert integer to its byte array format
      Parameters:
      v - an input integer value
      Returns:
      the big endian byte array representation
    • fromBDBytes

      public static int fromBDBytes(byte[] bytes)
      convert into its integer representation
      Parameters:
      bytes - the big endian integer's byte array
      Returns:
      a integer corresponding to input bytes
    • setByte

      public static int setByte(int v, byte bv, int pos)
      set a specified position byte to another value to return a fresh integer
      Parameters:
      v - the input integer value
      bv - the byte value to insert
      pos - the position of an 4 byte array to replace
      Returns:
      a fresh integer after a specified position byte been replaced
    • shiftLeftFromSpecifiedPosition

      public static int shiftLeftFromSpecifiedPosition(int v, int pos, int count)
      shift the byte left from the specified position
      Parameters:
      v - a integer value
      pos - the position from which to shift byte values left
      count - the shifting numbers
      Returns:
      a fresh integer value
    • firstByte

      public static byte firstByte(int v)
      fetch the first byte
      Parameters:
      v - an input integer
      Returns:
      the first byte of the big endian representation