Package com.graphhopper.util
Class BitUtil
java.lang.Object
com.graphhopper.util.BitUtil
LITTLE endianness is default for GraphHopper and most microprocessors.
- Author:
- Peter Karich
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcountBitValue(int maxTurnCosts) byte[]fromBitString(String str) final voidfromDouble(byte[] bytes, double value) final voidfromDouble(byte[] bytes, double value, int offset) final byte[]fromDouble(double value) final voidfromFloat(byte[] bytes, float value) final voidfromFloat(byte[] bytes, float value, int offset) final byte[]fromFloat(float value) final voidfromInt(byte[] bytes, int value) final voidfromInt(byte[] bytes, int value, int offset) final byte[]fromInt(int value) final voidfromLong(byte[] bytes, long value) final voidfromLong(byte[] bytes, long value, int offset) final byte[]fromLong(long value) final voidfromShort(byte[] bytes, short value) voidfromShort(byte[] bytes, short value, int offset) final byte[]fromShort(short value) final voidfromUInt3(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 intgetIntHigh(long longValue) final intgetIntLow(long longValue) toBitString(byte[] bytes) Higher order bits comes first in the returned string.final StringtoBitString(long value) Similar to Long.toBinaryStringtoBitString(long value, int bits) Higher order bits comes first in the returned string.final doubletoDouble(byte[] bytes) final doubletoDouble(byte[] bytes, int offset) final floattoFloat(byte[] bytes) final floattoFloat(byte[] bytes, int offset) final inttoInt(byte[] b) final inttoInt(byte[] b, int offset) toLastBitString(long value, int bits) final longtoLong(byte[] b) See the counterpartfromLong(long)final longtoLong(byte[] b, int offset) final longtoLong(int intLow, int intHigh) final shorttoShort(byte[] b) final shorttoShort(byte[] b, int offset) static inttoSignedInt(long x) Converts the specified long into a signed int ('reverse' method for Integer.toUnsignedLong).final inttoUInt3(byte[] b, int offset)
-
Field Details
-
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 counterpartfromLong(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
-
toBitString
Similar to Long.toBinaryString -
toLastBitString
-
toBitString
Higher order bits comes first in the returned string.- Parameters:
bits- how many bits should be returned.
-
toBitString
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).
-