Class BitUtil

java.lang.Object
com.graphhopper.util.BitUtil

public class BitUtil extends Object
LITTLE endianness is default for GraphHopper and most microprocessors.
Author:
Peter Karich
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BitUtil
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    countBitValue(int maxTurnCosts)
     
    byte[]
     
    final void
    fromDouble(byte[] bytes, double value)
     
    final void
    fromDouble(byte[] bytes, double value, int offset)
     
    final byte[]
    fromDouble(double value)
     
    final void
    fromFloat(byte[] bytes, float value)
     
    final void
    fromFloat(byte[] bytes, float value, int offset)
     
    final byte[]
    fromFloat(float value)
     
    final void
    fromInt(byte[] bytes, int value)
     
    final void
    fromInt(byte[] bytes, int value, int offset)
     
    final byte[]
    fromInt(int value)
     
    final void
    fromLong(byte[] bytes, long value)
     
    final void
    fromLong(byte[] bytes, long value, int offset)
     
    final byte[]
    fromLong(long value)
     
    final void
    fromShort(byte[] bytes, short value)
     
    void
    fromShort(byte[] bytes, short value, int offset)
     
    final byte[]
    fromShort(short value)
     
    final void
    fromUInt3(byte[] bytes, int value, int offset)
    Note, currently value with higher bits set (like for a negative value) won't throw an exception at this level.
    final int
    getIntHigh(long longValue)
     
    final int
    getIntLow(long longValue)
     
    toBitString(byte[] bytes)
    Higher order bits comes first in the returned string.
    final String
    toBitString(long value)
    Similar to Long.toBinaryString
    toBitString(long value, int bits)
    Higher order bits comes first in the returned string.
    final double
    toDouble(byte[] bytes)
     
    final double
    toDouble(byte[] bytes, int offset)
     
    final float
    toFloat(byte[] bytes)
     
    final float
    toFloat(byte[] bytes, int offset)
     
    final int
    toInt(byte[] b)
     
    final int
    toInt(byte[] b, int offset)
     
    toLastBitString(long value, int bits)
     
    final long
    toLong(byte[] b)
    See the counterpart fromLong(long)
    final long
    toLong(byte[] b, int offset)
     
    final long
    toLong(int intLow, int intHigh)
     
    final short
    toShort(byte[] b)
     
    final short
    toShort(byte[] b, int offset)
     
    static int
    toSignedInt(long x)
    Converts the specified long into a signed int ('reverse' method for Integer.toUnsignedLong).
    final int
    toUInt3(byte[] b, int offset)
     

    Methods inherited from class java.lang.Object

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

    • LITTLE

      public static final BitUtil LITTLE
  • Constructor Details

    • BitUtil

      public BitUtil()
  • Method Details

    • toDouble

      public final double toDouble(byte[] bytes)
    • toDouble

      public final double toDouble(byte[] bytes, int offset)
    • fromDouble

      public final byte[] fromDouble(double value)
    • fromDouble

      public final void fromDouble(byte[] bytes, double value)
    • fromDouble

      public final void fromDouble(byte[] bytes, double value, int offset)
    • toFloat

      public final float toFloat(byte[] bytes)
    • toFloat

      public final float toFloat(byte[] bytes, int offset)
    • fromFloat

      public final byte[] fromFloat(float value)
    • fromFloat

      public final void fromFloat(byte[] bytes, float value)
    • fromFloat

      public final void fromFloat(byte[] bytes, float value, int offset)
    • toShort

      public final short toShort(byte[] b)
    • toShort

      public final short toShort(byte[] b, int offset)
    • toInt

      public final int toInt(byte[] b)
    • toInt

      public final int toInt(byte[] b, int offset)
    • toUInt3

      public final int toUInt3(byte[] b, int offset)
    • fromInt

      public final byte[] fromInt(int value)
    • fromInt

      public final void fromInt(byte[] bytes, int value)
    • fromShort

      public final byte[] fromShort(short value)
    • fromShort

      public final void fromShort(byte[] bytes, short value)
    • fromShort

      public void fromShort(byte[] bytes, short value, int offset)
    • fromInt

      public final void fromInt(byte[] bytes, int value, int offset)
    • fromUInt3

      public final void fromUInt3(byte[] bytes, int value, int offset)
      Note, currently value with higher bits set (like for a negative value) won't throw an exception at this level.
    • toLong

      public final long toLong(byte[] b)
      See the counterpart fromLong(long)
    • toLong

      public final long toLong(int intLow, int intHigh)
    • toLong

      public final long toLong(byte[] b, int offset)
    • fromLong

      public final byte[] fromLong(long value)
    • fromLong

      public final void fromLong(byte[] bytes, long value)
    • fromLong

      public final void fromLong(byte[] bytes, long value, int offset)
    • fromBitString

      public byte[] fromBitString(String str)
    • toBitString

      public final String toBitString(long value)
      Similar to Long.toBinaryString
    • toLastBitString

      public String toLastBitString(long value, int bits)
    • toBitString

      public String toBitString(long value, int bits)
      Higher order bits comes first in the returned string.

      Parameters:
      bits - how many bits should be returned.
    • toBitString

      public String toBitString(byte[] bytes)
      Higher order bits comes first in the returned string.
    • getIntLow

      public final int getIntLow(long longValue)
    • getIntHigh

      public final int getIntHigh(long longValue)
    • countBitValue

      public static int countBitValue(int maxTurnCosts)
    • toSignedInt

      public static int toSignedInt(long x)
      Converts the specified long into a signed int ('reverse' method for Integer.toUnsignedLong).