Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.utilities
Class ByteArrayUtil

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.utilities.ByteArrayUtil

public final class ByteArrayUtil
extends Object

Class with various utilities for manipulating byte arrays. If you find a reusable copy of this in the Java API, please tell me. Using a ByteArrayOutputStream and DataInputStream doesn't seem appropriate. C.f. DataOutputStream and ByteArrayOutputStream

Author:
Erich Schubert

Constructor Summary
ByteArrayUtil()
           
 
Method Summary
static double readDouble(byte[] array, int offset)
          Read a double from the byte array at the given offset.
static float readFloat(byte[] array, int offset)
          Read a float from the byte array at the given offset.
static int readInt(byte[] array, int offset)
          Read an integer from the byte array at the given offset.
static long readLong(byte[] array, int offset)
          Read a long from the byte array at the given offset.
static short readShort(byte[] array, int offset)
          Read a short from the byte array at the given offset.
static int readUnsignedShort(byte[] array, int offset)
          Read an unsigned short from the byte array at the given offset.
static void writeDouble(byte[] array, int offset, double v)
          Write a double to the byte array at the given offset.
static void writeFloat(byte[] array, int offset, float v)
          Write a float to the byte array at the given offset.
static void writeInt(byte[] array, int offset, int v)
          Write an integer to the byte array at the given offset.
static void writeLong(byte[] array, int offset, long v)
          Write a long to the byte array at the given offset.
static void writeShort(byte[] array, int offset, int v)
          Write a short to the byte array at the given offset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArrayUtil

public ByteArrayUtil()
Method Detail

writeShort

public static final void writeShort(byte[] array,
                                    int offset,
                                    int v)
Write a short to the byte array at the given offset.

Parameters:
array - Array to write to
offset - Offset to write to
v - data

writeInt

public static final void writeInt(byte[] array,
                                  int offset,
                                  int v)
Write an integer to the byte array at the given offset.

Parameters:
array - Array to write to
offset - Offset to write to
v - data

writeLong

public static final void writeLong(byte[] array,
                                   int offset,
                                   long v)
Write a long to the byte array at the given offset.

Parameters:
array - Array to write to
offset - Offset to write to
v - data

writeFloat

public static final void writeFloat(byte[] array,
                                    int offset,
                                    float v)
Write a float to the byte array at the given offset.

Parameters:
array - Array to write to
offset - Offset to write to
v - data

writeDouble

public static final void writeDouble(byte[] array,
                                     int offset,
                                     double v)
Write a double to the byte array at the given offset.

Parameters:
array - Array to write to
offset - Offset to write to
v - data

readShort

public static final short readShort(byte[] array,
                                    int offset)
Read a short from the byte array at the given offset.

Parameters:
array - Array to read from
offset - Offset to read at
Returns:
(signed) short

readUnsignedShort

public static final int readUnsignedShort(byte[] array,
                                          int offset)
Read an unsigned short from the byte array at the given offset.

Parameters:
array - Array to read from
offset - Offset to read at
Returns:
short

readInt

public static final int readInt(byte[] array,
                                int offset)
Read an integer from the byte array at the given offset.

Parameters:
array - Array to read from
offset - Offset to read at
Returns:
data

readLong

public static final long readLong(byte[] array,
                                  int offset)
Read a long from the byte array at the given offset.

Parameters:
array - Array to read from
offset - Offset to read at
Returns:
data

readFloat

public static final float readFloat(byte[] array,
                                    int offset)
Read a float from the byte array at the given offset.

Parameters:
array - Array to read from
offset - Offset to read at
Returns:
data

readDouble

public static final double readDouble(byte[] array,
                                      int offset)
Read a double from the byte array at the given offset.

Parameters:
array - Array to read from
offset - Offset to read at
Returns:
data

Release 0.3 (2010-03-31_1612)