public final class UnsignedShortBuffer extends UnsignedBufferAsInt
ShortBuffer
but automatically performs conversion to int
.
The conversion applies to ShortBuffer.get()
and ShortBuffer.put(short)
of single
elements, but not to any mass get or put operations.
The user has a choice of getting/setting using raw (getRaw()
, putRaw(short)
etc.) or
unsigned-conversion (getUnsigned()
, putUnsigned(int)
etc.) methods. The raw methods
are always more efficient, and so should be preferred when conversion is not needed.
Modifier and Type | Method and Description |
---|---|
static UnsignedShortBuffer |
allocate(int capacity)
Allocates a new (direct) buffer of unsigned-shorts.
|
short[] |
array()
The array of the buffer ala
ShortBuffer.array() . |
protected boolean |
canEqual(Object other) |
boolean |
equals(Object o) |
ShortBuffer |
getDelegate()
The underlying storage buffer, to which calls are delegated with our without conversion.
|
short |
getRaw()
Gets an unsigned-short (represented as a short) at the current buffer position.
|
short |
getRaw(int index)
Gets an unsigned-short (represented as a short) at a particular buffer position.
|
int |
getUnsigned()
Gets an unsigned-byte (represented as a int) at the current buffer position.
|
int |
getUnsigned(int index)
Gets an unsigned-byte (represented as a int) at a particular buffer position.
|
int |
hashCode() |
void |
put(ShortBuffer source)
Relative put-method from an unsigned short buffer, represented by a
ShortBuffer . |
void |
put(UnsignedShortBuffer source)
Relative put-method from an unsigned short buffer, represented by a
UnsignedShortBuffer . |
void |
putDouble(double value)
Puts a double at the current buffer position.
|
void |
putDouble(int index,
double value)
Puts a double at a particular buffer position.
|
void |
putFloat(float value)
Puts a float at the current buffer position.
|
void |
putFloat(int index,
float value)
Puts a float at a particular buffer position.
|
void |
putFloatClamped(float value)
Puts a float at the current buffer position, clamping to ensure the value is within the range
(0,255) . |
void |
putLong(long value)
Puts a long at the current buffer position.
|
void |
putLongClamped(long value)
Puts a long at the current buffer position, clamping to ensure the value is within the range
(0,255) . |
void |
putRaw(int index,
short value)
Puts an unsigned-short (represented as a short) a particular buffer position.
|
void |
putRaw(short value)
Puts an unsigned-short (represented as a short) at the current buffer position.
|
void |
putUnsigned(int value)
Puts an unsigned-byte (represented by an int) at current buffer position.
|
void |
putUnsigned(int index,
int value)
Puts an unsigned-byte (represented as a int) a particular buffer position.
|
void |
putUnsignedClamped(int value)
Puts a long at the current buffer position, clamping to ensure the value is within the range
(0,255) . |
static UnsignedShortBuffer |
wrapRaw(short[] array)
Exposes a raw short-array as a buffer with unsigned-shorts.
|
static UnsignedShortBuffer |
wrapRaw(ShortBuffer bufferRaw)
Exposes a raw
UnsignedShortBuffer as a buffer with unsigned-shorts. |
toString
capacity, clear, hasArray, hasRemaining, isDirect, position, position
public static UnsignedShortBuffer allocate(int capacity)
capacity
- size of buffer.public static UnsignedShortBuffer wrapRaw(short[] array)
array
- the short-array.UnsignedShortBuffer
that reuses array
internally.public static UnsignedShortBuffer wrapRaw(ShortBuffer bufferRaw)
UnsignedShortBuffer
as a buffer with unsigned-shorts.bufferRaw
- the raw-bufferUnsignedShortBuffer
that reuses bufferRaw
internally.public short getRaw()
No further conversion occurs, so this method is more efficient than getUnsigned()
.
public short getRaw(int index)
No further conversion occurs, so this method is more efficient than getUnsigned(int)
.
index
- the buffer positionpublic int getUnsigned()
UnsignedBufferAsInt
getUnsigned
in class UnsignedBufferAsInt
public int getUnsigned(int index)
UnsignedBufferAsInt
getUnsigned
in class UnsignedBufferAsInt
index
- the buffer positionpublic void putRaw(short value)
No further conversion occurs, so this method is more efficient than putUnsigned(int)
.
value
- unsigned-short (represented by a short)public void putRaw(int index, short value)
No further conversion occurs, so this method is more efficient than putUnsigned(int,int)
.
index
- the buffer positionvalue
- the unsigned-short (represented by an short)public void putUnsigned(int value)
UnsignedBufferAsInt
A conversion occurs from int to byte.
putUnsigned
in class UnsignedBufferAsInt
value
- the unsigned-byte (represented by an int)public void putUnsignedClamped(int value)
(0,255)
.value
- the floatpublic void putUnsigned(int index, int value)
UnsignedBufferAsInt
A conversion occurs from int to byte.
putUnsigned
in class UnsignedBufferAsInt
index
- the buffer positionvalue
- the unsigned-byte (represented by an int)public void putLong(long value)
UnsignedBuffer
putLong
in class UnsignedBuffer
value
- the long.public void putLongClamped(long value)
(0,255)
.value
- the floatpublic void putFloat(float value)
UnsignedBuffer
A conversion occurs from float to short.
putFloat
in class UnsignedBuffer
value
- the float.public void putFloatClamped(float value)
(0,255)
.value
- the floatpublic void putFloat(int index, float value)
UnsignedBuffer
A conversion occurs from float to byte.
putFloat
in class UnsignedBuffer
index
- the buffer positionvalue
- the float.public void putDouble(double value)
UnsignedBuffer
putDouble
in class UnsignedBuffer
value
- the doublepublic void putDouble(int index, double value)
UnsignedBuffer
putDouble
in class UnsignedBuffer
index
- the buffer positionvalue
- the doublepublic void put(ShortBuffer source)
ShortBuffer
.
This is identical to ShortBuffer.put(ShortBuffer)
, with no return value.
source
- source of bytes to putpublic void put(UnsignedShortBuffer source)
UnsignedShortBuffer
.
This is identical to ShortBuffer.put(ShortBuffer)
, with no return value.
source
- source of bytes to putpublic final short[] array()
ShortBuffer.array()
.
Unlike ShortBuffer.array()
an array will always be returned, copying it into a newly
created array, if it cannot be directly accessed.
public boolean equals(Object o)
equals
in class UnsignedBufferAsInt
protected boolean canEqual(Object other)
canEqual
in class UnsignedBufferAsInt
public int hashCode()
hashCode
in class UnsignedBufferAsInt
public ShortBuffer getDelegate()
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.