DataBuffers

public final class DataBuffers

Helper class for creating DataBuffer instances.

Public Constructors

Public Methods

static FloatDataBuffer
of(FloatBuffer buf)
Wraps a JDK NIO FloatBuffer into a data buffer.
static LongDataBuffer
of(long[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of longs into a data buffer.
static <T> DataBuffer<T>
of(T[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of objects into a data buffer.
static DoubleDataBuffer
of(double[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of doubles into a data buffer.
static ShortDataBuffer
of(short... values)
Create a buffer from an array of shorts into a data buffer.
static IntDataBuffer
of(IntBuffer buf)
Wraps a JDK NIO IntBuffer into a data buffer.
static DoubleDataBuffer
of(DoubleBuffer buf)
Wraps a JDK NIO DoubleBuffer into a data buffer.
static ByteDataBuffer
of(byte... values)
Create a buffer from an array of bytes into a data buffer.
static LongDataBuffer
of(long... values)
Create a buffer from an array of longs into a data buffer.
static ByteDataBuffer
of(ByteBuffer buf)
Wraps a JDK NIO ByteBuffer into a data buffer.
static DoubleDataBuffer
of(double... values)
Create a buffer from an array of doubles into a data buffer.
static FloatDataBuffer
of(float[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of floats into a data buffer.
static BooleanDataBuffer
of(boolean[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of booleans into a data buffer.
static ShortDataBuffer
of(ShortBuffer buf)
Wraps a JDK NIO ShortBuffer into a data buffer.
static ShortDataBuffer
of(short[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of shorts into a data buffer.
static LongDataBuffer
of(LongBuffer buf)
Wraps a JDK NIO LongBuffer into a data buffer.
static ByteDataBuffer
of(byte[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of bytes into a data buffer.
static IntDataBuffer
of(int[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of ints into a data buffer.
static FloatDataBuffer
of(float... values)
Create a buffer from an array of floats into a data buffer.
static BooleanDataBuffer
of(boolean... values)
Create a buffer from an array of booleans into a data buffer.
static IntDataBuffer
of(int... values)
Create a buffer from an array of ints into a data buffer.
static BooleanDataBuffer
ofBooleans(long size)
Creates a buffer of booleans that can store up to size values
static ByteDataBuffer
ofBytes(long size)
Creates a buffer of bytes that can store up to size values
static DoubleDataBuffer
ofDoubles(long size)
Creates a buffer of doubles that can store up to size values
static FloatDataBuffer
ofFloats(long size)
Creates a buffer of floats that can store up to size values
static IntDataBuffer
ofInts(long size)
Creates a buffer of integers that can store up to size values
static LongDataBuffer
ofLongs(long size)
Creates a buffer of longs that can store up to size values
static <T> DataBuffer<T>
ofObjects(Class<T> type, long size)
Creates a buffer of references to objects of type clazz` that can store up to `size values.
static <T> DataBuffer<T>
ofObjects(T... values)
Create a buffer from an array of objects into a data buffer.
static ShortDataBuffer
ofShorts(long size)
Creates a buffer of shorts that can store up to size values

Inherited Methods

boolean
equals(Object arg0)
final Class<?>
getClass()
int
hashCode()
final void
notify()
final void
notifyAll()
String
toString()
final void
wait(long arg0, int arg1)
final void
wait(long arg0)
final void
wait()

Public Constructors

public DataBuffers ()

Public Methods

public static FloatDataBuffer of (FloatBuffer buf)

Wraps a JDK NIO FloatBuffer into a data buffer.

Parameters
buf buffer to wrap
Returns
  • a new buffer

public static LongDataBuffer of (long[] array, boolean readOnly, boolean makeCopy)

Create a buffer from an array of longs into a data buffer.

Parameters
array array of longs
readOnly true if the buffer created must be read-only
makeCopy true if the array must be copied, false will wrap the provided array
Returns
  • a new buffer

public static DataBuffer<T> of (T[] array, boolean readOnly, boolean makeCopy)

Create a buffer from an array of objects into a data buffer.

Parameters
array array of objects
readOnly true if the buffer created must be read-only
makeCopy true if the array must be copied, false will wrap the provided array
Returns
  • a new buffer

public static DoubleDataBuffer of (double[] array, boolean readOnly, boolean makeCopy)

Create a buffer from an array of doubles into a data buffer.

Parameters
array array of doubles
readOnly true if the buffer created must be read-only
makeCopy true if the array must be copied, false will wrap the provided array
Returns
  • a new buffer

public static ShortDataBuffer of (short... values)

Create a buffer from an array of shorts into a data buffer.

The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call of(values, false, false}

Parameters
values short values
Returns
  • a new buffer

public static IntDataBuffer of (IntBuffer buf)

Wraps a JDK NIO IntBuffer into a data buffer.

Parameters
buf buffer to wrap
Returns
  • a new buffer

public static DoubleDataBuffer of (DoubleBuffer buf)

Wraps a JDK NIO DoubleBuffer into a data buffer.

Parameters
buf buffer to wrap
Returns
  • a new buffer

public static ByteDataBuffer of (byte... values)

Create a buffer from an array of bytes into a data buffer.

The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call of(values, false, false}

Parameters
values byte values
Returns
  • a new buffer

public static LongDataBuffer of (long... values)

Create a buffer from an array of longs into a data buffer.

The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call of(values, false, false}

Parameters
values long values
Returns
  • a new buffer

public static ByteDataBuffer of (ByteBuffer buf)

Wraps a JDK NIO ByteBuffer into a data buffer.

Parameters
buf buffer to wrap
Returns
  • a new buffer

public static DoubleDataBuffer of (double... values)

Create a buffer from an array of doubles into a data buffer.

The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call of(array, false, false}

Parameters
values double values
Returns
  • a new buffer

public static FloatDataBuffer of (float[] array, boolean readOnly, boolean makeCopy)

Create a buffer from an array of floats into a data buffer.

Parameters
array array of floats
readOnly true if the buffer created must be read-only
makeCopy true if the array must be copied, false will wrap the provided array
Returns
  • a new buffer

public static BooleanDataBuffer of (boolean[] array, boolean readOnly, boolean makeCopy)

Create a buffer from an array of booleans into a data buffer.

Parameters
array array of booleans
readOnly true if the buffer created must be read-only
makeCopy true if the array must be copied, false will wrap the provided array
Returns
  • a new buffer

public static ShortDataBuffer of (ShortBuffer buf)

Wraps a JDK NIO ShortBuffer into a data buffer.

Parameters
buf buffer to wrap
Returns
  • a new buffer

public static ShortDataBuffer of (short[] array, boolean readOnly, boolean makeCopy)

Create a buffer from an array of shorts into a data buffer.

Parameters
array array of shorts
readOnly true if the buffer created must be read-only
makeCopy true if the array must be copied, false will wrap the provided array
Returns
  • a new buffer

public static LongDataBuffer of (LongBuffer buf)

Wraps a JDK NIO LongBuffer into a data buffer.

Parameters
buf buffer to wrap
Returns
  • a new buffer

public static ByteDataBuffer of (byte[] array, boolean readOnly, boolean makeCopy)

Create a buffer from an array of bytes into a data buffer.

Parameters
array array of bytes
readOnly true if the buffer created must be read-only
makeCopy true if the array must be copied, false will wrap the provided array
Returns
  • a new buffer

public static IntDataBuffer of (int[] array, boolean readOnly, boolean makeCopy)

Create a buffer from an array of ints into a data buffer.

Parameters
array array of ints
readOnly true if the buffer created must be read-only
makeCopy true if the array must be copied, false will wrap the provided array
Returns
  • a new buffer

public static FloatDataBuffer of (float... values)

Create a buffer from an array of floats into a data buffer.

The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call of(values, false, false}

Parameters
values float values
Returns
  • a new buffer

public static BooleanDataBuffer of (boolean... values)

Create a buffer from an array of booleans into a data buffer.

The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call of(values, false, false}

Parameters
values booleans values
Returns
  • a new buffer

public static IntDataBuffer of (int... values)

Create a buffer from an array of ints into a data buffer.

The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call of(values, false, false}

Parameters
values int values
Returns
  • a new buffer

public static BooleanDataBuffer ofBooleans (long size)

Creates a buffer of booleans that can store up to size values

Parameters
size size of the buffer to allocate
Returns
  • a new buffer

public static ByteDataBuffer ofBytes (long size)

Creates a buffer of bytes that can store up to size values

Parameters
size size of the buffer to allocate
Returns
  • a new buffer

public static DoubleDataBuffer ofDoubles (long size)

Creates a buffer of doubles that can store up to size values

Parameters
size size of the buffer to allocate
Returns
  • a new buffer

public static FloatDataBuffer ofFloats (long size)

Creates a buffer of floats that can store up to size values

Parameters
size size of the buffer to allocate
Returns
  • a new buffer

public static IntDataBuffer ofInts (long size)

Creates a buffer of integers that can store up to size values

Parameters
size size of the buffer to allocate
Returns
  • a new buffer

public static LongDataBuffer ofLongs (long size)

Creates a buffer of longs that can store up to size values

Parameters
size size of the buffer to allocate
Returns
  • a new buffer

public static DataBuffer<T> ofObjects (Class<T> type, long size)

Creates a buffer of references to objects of type clazz` that can store up to `size values.

Parameters
type the type of object stored in this buffer
size size of the buffer to allocate
Returns
  • a new buffer

public static DataBuffer<T> ofObjects (T... values)

Create a buffer from an array of objects into a data buffer.

The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call of(values, false, false}

Parameters
values objects values
Returns
  • a new buffer

public static ShortDataBuffer ofShorts (long size)

Creates a buffer of shorts that can store up to size values

Parameters
size size of the buffer to allocate
Returns
  • a new buffer