public abstract class AbstractDataBuffer<T> extends Object implements DataBuffer<T>
| Constructor and Description |
|---|
AbstractDataBuffer() |
| Modifier and Type | Method and Description |
|---|---|
DataBuffer<T> |
copyTo(DataBuffer<T> dst,
long size)
Write the references of the objects in the source array into this buffer.
|
boolean |
equals(Object obj)
Checks equality between data buffers.
|
int |
hashCode() |
DataBuffer<T> |
read(T[] dst,
int offset,
int length)
Read the references of the objects in this buffer into the destination array.
|
protected <U extends DataBuffer<T>> |
slowCopyTo(DataBuffer<T> dst,
long size) |
protected boolean |
slowEquals(DataBuffer<?> other) |
protected int |
slowHashCode() |
DataBuffer<T> |
write(T[] src,
int offset,
int length)
Bulk put method, using int arrays.
|
public DataBuffer<T> read(T[] dst, int offset, int length)
DataBuffer
This method transfers values from this buffer into the given destination array. If there are
fewer values in the buffer than are required to satisfy the request, that is, if
length > size(), then no values are transferred and a
BufferUnderflowException is thrown.
Otherwise, this method copies n = length values from this buffer into the given array
starting at the given offset.
read in interface DataBuffer<T>dst - the array into which values are to be writtenoffset - the offset within the array of the first value to be written; must be
non-negative and no larger than dst.lengthlength - the maximum number of values to be written to the given array; must be
non-negative and no larger than dst.length - offsetpublic DataBuffer<T> write(T[] src, int offset, int length)
DataBuffer
This method transfers the values in the given source array into this buffer. If there are
more values in the source array than in this buffer, that is, if
length > size(), then no values are transferred and a
BufferOverflowException is thrown.
Otherwise, this method copies n = length values from the given array into this buffer,
starting at the given offset.
write in interface DataBuffer<T>src - the source array from which values are to be readoffset - the offset within the array of the first value to be read; must be non-negative
and no larger than src.lengthlength - the number of values to be read from the given array; must be non-negative and no
larger than src.length - offsetpublic DataBuffer<T> copyTo(DataBuffer<T> dst, long size)
DataBuffer
If there are more values to copy than the destination buffer size, i.e.
size > dst.size(), then no values are transferred and a
BufferOverflowException is thrown. On the other hand, if there are more values to copy that
the source buffer size, i.e. > src.size(), then a BufferUnderfloatException is thrown.
Otherwise, this method copies n = size values from this buffer into
the destination buffer.
copyTo in interface DataBuffer<T>dst - the destination buffer into which values are copied; must not be this buffersize - number of values to copy to the destination bufferpublic boolean equals(Object obj)
DataBufferA data buffer is equal to another object if this object is another DataBuffer of the
same size, type and the elements are equal and in the same order. For example:
IntDataBuffer buffer = DataBuffers.of(1, 2, 3);
assertEquals(buffer, DataBuffers.of(1, 2, 3)); // true
assertEquals(buffer, DataBuffers.ofObjects(1, 2, 3)); // true, as Integers are equal to ints
assertNotEquals(buffer, DataBuffers.of(1, 2, 3, 0)); // false, different sizes
assertNotEquals(buffer, DataBuffers.of(1, 3, 2)); // false, different order
assertNotEquals(buffer, DataBuffers.of(1L, 2L, 3L)); // false, different types
Note that the computation required to verify equality between two buffers can be expensive in some cases and therefore, it is recommended to not use this method in a critical path where performances matter.
equals in interface DataBuffer<T>equals in class Objectobj - object to compare this buffer withprotected <U extends DataBuffer<T>> U slowCopyTo(DataBuffer<T> dst, long size)
protected int slowHashCode()
protected boolean slowEquals(DataBuffer<?> other)
Copyright © 2015–2020. All rights reserved.