Class PrimitiveArrayUtils
java.lang.Object
org.greenrobot.essentials.PrimitiveArrayUtils
- Direct Known Subclasses:
PrimitiveArrayUtils.SafeImpl, PrimitiveArrayUtils.UnsafeImpl
Retrieves int and long values from byte arrays. By default it uses a "safe" implementation (plain Java).
By calling
initUnsafeInstance(), you can switch to sun.misc.Unsafe (deprecated) for fast access.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final PrimitiveArrayUtilsprivate static PrimitiveArrayUtils -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PrimitiveArrayUtilsstatic PrimitiveArrayUtilsabstract intgetIntBE(byte[] bytes, int index) abstract intgetIntLE(byte[] bytes, int index) abstract intgetIntLE(char[] chars, int index) abstract longgetLongBE(byte[] bytes, int index) abstract longgetLongLE(byte[] bytes, int index) static booleanIf sun.misc.Unsafe is available, this will init the static instance with a fast implementation.
-
Field Details
-
instanceUnsafe
-
instanceSafe
-
-
Constructor Details
-
PrimitiveArrayUtils
public PrimitiveArrayUtils()
-
-
Method Details
-
getInstance
-
initUnsafeInstance
public static boolean initUnsafeInstance()If sun.misc.Unsafe is available, this will init the static instance with a fast implementation.- Returns:
- true if an unsafe implementation is available - future calls to
getInstance()will return it.
-
getInstanceSafe
-
getIntLE
public abstract int getIntLE(byte[] bytes, int index) -
getIntBE
public abstract int getIntBE(byte[] bytes, int index) -
getLongLE
public abstract long getLongLE(byte[] bytes, int index) -
getLongBE
public abstract long getLongBE(byte[] bytes, int index) -
getIntLE
public abstract int getIntLE(char[] chars, int index)
-