Class AbstractDataBuffer<T>
- All Implemented Interfaces:
DataBuffer<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopyTo(DataBuffer<T> dst, long size) Write the references of the objects in the source array into this buffer.booleanChecks equality between data buffers.inthashCode()Read the references of the objects in this buffer into the destination array.protected <U extends DataBuffer<T>>
UslowCopyTo(DataBuffer<T> dst, long size) protected booleanslowEquals(DataBuffer<?> other) protected intBulk put method, using int arrays.
-
Constructor Details
-
AbstractDataBuffer
public AbstractDataBuffer()
-
-
Method Details
-
read
Description copied from interface:DataBufferRead the references of the objects in this buffer into the destination array.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 = lengthvalues from this buffer into the given array starting at the given offset.- Specified by:
readin interfaceDataBuffer<T>- Parameters:
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 thandst.lengthlength- the maximum number of values to be written to the given array; must be non-negative and no larger thandst.length - offset- Returns:
- this buffer
-
write
Description copied from interface:DataBufferBulk put method, using int arrays.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 = lengthvalues from the given array into this buffer, starting at the given offset.- Specified by:
writein interfaceDataBuffer<T>- Parameters:
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 thansrc.lengthlength- the number of values to be read from the given array; must be non-negative and no larger thansrc.length - offset- Returns:
- this buffer
-
copyTo
Description copied from interface:DataBufferWrite the references of the objects in the source array into this buffer.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 = sizevalues from this buffer into the destination buffer.- Specified by:
copyToin interfaceDataBuffer<T>- Parameters:
dst- the destination buffer into which values are copied; must not be this buffersize- number of values to copy to the destination buffer- Returns:
- this buffer
-
hashCode
-
equals
Description copied from interface:DataBufferChecks equality between data buffers.A data buffer is equal to another object if this object is another
DataBufferof 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 typesNote 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.
- Specified by:
equalsin interfaceDataBuffer<T>- Overrides:
equalsin classObject- Parameters:
obj- object to compare this buffer with- Returns:
- true if this buffer is equal to the provided object
-
slowCopyTo
-
slowHashCode
protected int slowHashCode() -
slowEquals
-