public interface ShortDataBuffer extends DataBuffer<Short>
DataBuffer of shorts.| Modifier and Type | Method and Description |
|---|---|
ShortDataBuffer |
copyTo(DataBuffer<Short> dst,
long size)
Write the references of the objects in the source array into this buffer.
|
default Short |
getObject(long index)
Reads the value at the given index.
|
short |
getShort(long index)
Reads the short at the given index.
|
default ShortDataBuffer |
narrow(long size)
Creates a new buffer whose content is a shared subsequence of this buffer's content, whose
size is set to the given value.
|
default ShortDataBuffer |
offset(long index)
Creates a new buffer whose content is a shared subsequence of this buffer's content, starting
at the given index.
|
default ShortDataBuffer |
read(short[] dst)
Bulk get method, using short arrays.
|
ShortDataBuffer |
read(short[] dst,
int offset,
int length)
Bulk get method, using short arrays.
|
default ShortDataBuffer |
setObject(Short value,
long index)
Writes the given value into this buffer at the given index.
|
ShortDataBuffer |
setShort(short value,
long index)
Writes the given short into this buffer at the given index.
|
ShortDataBuffer |
slice(long index,
long size)
Creates a new buffer whose content is a shared subsequence of this buffer's content, starting
at the given index and of the given size.
|
default DataBufferWindow<ShortDataBuffer> |
window(long size)
Creates a
DataBufferWindow that provides a partial view of this buffer. |
default ShortDataBuffer |
write(short[] src)
Bulk put method, using short arrays.
|
ShortDataBuffer |
write(short[] src,
int offset,
int length)
Bulk put method, using short arrays.
|
accept, equals, isReadOnly, read, read, size, write, writeshort getShort(long index)
index - the index from which the float will be readIndexOutOfBoundsException - if index is negative or not smaller than the buffer sizeShortDataBuffer setShort(short value, long index)
value - the short to be writtenindex - the index at which the value will be writtenIndexOutOfBoundsException - if index is negative or not smaller than the buffer sizeReadOnlyBufferException - if this buffer is read-onlydefault ShortDataBuffer read(short[] dst)
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
dst.length > size(), then no values are transferred and a
BufferUnderflowException is thrown.
Otherwise, this method copies n = dst.length values from this buffer into the given
array.
dst - the array into which values are to be writtenBufferUnderflowException - if there are not enough values to copy from this bufferShortDataBuffer read(short[] dst, int offset, int length)
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.
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 - offsetBufferUnderflowException - if there are fewer than length values remaining in this bufferIndexOutOfBoundsException - if the preconditions on the offset and length parameters do
not holddefault ShortDataBuffer write(short[] src)
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
src.length > size(), then no values are transferred and a
BufferOverflowException is thrown.
Otherwise, this method copies n = src.length values from the given array.
src - the source array from which values are to be readBufferOverflowException - if there is insufficient space in this buffer for the values in
the source arrayReadOnlyBufferException - if this buffer is read-onlyShortDataBuffer write(short[] src, int offset, int length)
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.
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 - offsetBufferOverflowException - if there is insufficient space in this buffer for the values in
the source arrayIndexOutOfBoundsException - if the preconditions on the offset and length parameters do
not holdReadOnlyBufferException - if this buffer is read-onlydefault Short getObject(long index)
DataBufferIntDataBuffer.getInt(idx)getObject in interface DataBuffer<Short>index - the index from which the float will be readdefault ShortDataBuffer setObject(Short value, long index)
DataBufferIntDataBuffer.setInt(idx)setObject in interface DataBuffer<Short>value - the value to be writtenindex - the index at which the value will be writtenShortDataBuffer copyTo(DataBuffer<Short> 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<Short>dst - the destination buffer into which values are copied; must not be this buffersize - number of values to copy to the destination bufferdefault ShortDataBuffer offset(long index)
DataBufferThe index must not be greater than this buffer size. Changes to this buffer's content will be visible in the new buffer and vice versa. The new buffer will be read-only if, and only if, this buffer is read-only.
This call is equivalent to slice(index, size() - index)
offset in interface DataBuffer<Short>index - index of the first value of the new buffer created, must not be greater than
size()default ShortDataBuffer narrow(long size)
DataBufferThe new size must not be greater than this buffer size. Changes to this buffer's content will be visible in the new buffer and vice versa. The new buffer will be read-only if, and only if, this buffer is read-only.
This call is equivalent to slice(0, size)
narrow in interface DataBuffer<Short>size - size of this new bufferShortDataBuffer slice(long index, long size)
DataBufferThe index plus the new size must not be greater than this buffer size. Changes to this buffer's content will be visible in the new buffer and vice versa. The new buffer will be read-only if, and only if, this buffer is read-only.
slice in interface DataBuffer<Short>index - index of the first value of the new buffer createdsize - size of this new buffer, must not be greater than size()default DataBufferWindow<ShortDataBuffer> window(long size)
DataBufferDataBufferWindow that provides a partial view of this buffer.
The created window has a fixed size and can "slide"
along this buffer to provide different views of the data without allocating a new buffer
instance, like DataBuffer.offset(long) does. This improves overall performance when this
operation is repeated frequently. For example:
IntDataBuffer bufferA = DataBuffers.ofInts(1024);
// ... init buffer data
IntDataBuffer bufferB = DataBuffers.ofInts(1, 2, 3, 4);
// Return the index of the first occurrence of bufferB in bufferA using a sliding window
DataBufferWindow<IntDataBuffer> windowA = bufferA.window(4);
for (int i = 0; i < bufferA.size() - bufferB.size(); ++i) {
if (windowA.slideTo(i).buffer().equals(bufferB)) {
return i;
}
}
The returned object is stateful and is not thread-safe.
window in interface DataBuffer<Short>size - size of the windowCopyright © 2015–2020. All rights reserved.