Class UnsignedIntBuffer
IntBuffer
but automatically performs conversion to long
.
The conversion applies to IntBuffer.get()
and IntBuffer.put(int)
of single elements,
but not to any mass get or put operations.
The user has a choice of getting/setting using raw (getRaw()
, putRaw(int)
etc.) or
unsigned-conversion (getUnsigned()
, putUnsigned(long)
etc.) methods. The raw methods
are always more efficient, and so should be preferred when conversion is not needed.
- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionstatic UnsignedIntBuffer
allocate
(int capacity) Allocates a new (direct) buffer of unsigned-ints.final int[]
array()
The array of the buffer alaIntBuffer.array()
.protected boolean
boolean
The underlying storage buffer, to which calls are delegated with our without conversion.int
getRaw()
Gets an unsigned-int (represented as an int) at the current buffer position.int
getRaw
(int index) Gets an unsigned-int (represented as a int) at a particular buffer position.long
Gets an unsigned-int (represented as a long) at the current buffer position.long
getUnsigned
(int index) Gets an unsigned-int (represented as a long) at a particular buffer position.int
hashCode()
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
putLong
(long value) Puts a long at the current buffer position.void
putRaw
(int value) Puts an unsigned-int (represented as a int) at the current buffer position.void
putRaw
(int index, int value) Puts an unsigned-int (represented as a int) a particular buffer position.void
putUnsigned
(int index, long value) Puts an unsigned-int (represented as a long) a particular buffer position.void
putUnsigned
(long value) Puts an unsigned-int (represented by a long) at current buffer position.static UnsignedIntBuffer
wrapRaw
(int[] array) Exposes a raw int-array as a buffer with unsigned-ints.static UnsignedIntBuffer
Exposes a rawUnsignedIntBuffer
as a buffer with unsigned-ints.Methods inherited from class org.anchoranalysis.image.voxel.buffer.primitive.UnsignedBuffer
capacity, clear, hasArray, hasRemaining, isDirect, position, position
-
Method Details
-
allocate
Allocates a new (direct) buffer of unsigned-ints.- Parameters:
capacity
- size of buffer.- Returns:
- newly created buffer (non-direct, i.e. backed by an array).
-
wrapRaw
Exposes a raw int-array as a buffer with unsigned-ints.- Parameters:
array
- the int-array- Returns:
- a new instance of
UnsignedIntBuffer
that reusesarray
internally.
-
wrapRaw
Exposes a rawUnsignedIntBuffer
as a buffer with unsigned-ints.- Parameters:
bufferRaw
- the raw-buffer- Returns:
- a new instance of
UnsignedIntBuffer
that reusesbufferRaw
internally.
-
getRaw
public int getRaw()Gets an unsigned-int (represented as an int) at the current buffer position.No further conversion occurs, so this method is more efficient than
getUnsigned()
.- Returns:
- unsigned-int (represented by an int)
-
getRaw
public int getRaw(int index) Gets an unsigned-int (represented as a int) at a particular buffer position.No further conversion occurs, so this method is more efficient than
getUnsigned(int)
.- Parameters:
index
- the buffer position- Returns:
- unsigned-int (represented by a int)
-
getUnsigned
public long getUnsigned()Gets an unsigned-int (represented as a long) at the current buffer position.- Returns:
- unsigned-int (represented by a long)
-
getUnsigned
public long getUnsigned(int index) Gets an unsigned-int (represented as a long) at a particular buffer position.- Parameters:
index
- the buffer position- Returns:
- unsigned-int (represented by a long)
-
putRaw
public void putRaw(int value) Puts an unsigned-int (represented as a int) at the current buffer position.No further conversion occurs, so this method is more efficient than
putUnsigned(long)
.- Parameters:
value
- unsigned-int (represented by a int)
-
putRaw
public void putRaw(int index, int value) Puts an unsigned-int (represented as a int) a particular buffer position.No further conversion occurs, so this method is more efficient than
putUnsigned(int,long)
.- Parameters:
index
- the buffer positionvalue
- the unsigned-int (represented by an int)
-
putUnsigned
public void putUnsigned(long value) Puts an unsigned-int (represented by a long) at current buffer position.A conversion occurs from long to int.
- Parameters:
value
- the unsigned-int (represented by a long)
-
putUnsigned
public void putUnsigned(int index, long value) Puts an unsigned-int (represented as a long) a particular buffer position.A conversion occurs from long to int.
- Parameters:
index
- the buffer positionvalue
- the unsigned-int (represented by a long)
-
putFloat
public void putFloat(float value) Description copied from class:UnsignedBuffer
Puts a float at the current buffer position.A conversion occurs from float to short.
- Specified by:
putFloat
in classUnsignedBuffer
- Parameters:
value
- the float.
-
putFloat
public void putFloat(int index, float value) Description copied from class:UnsignedBuffer
Puts a float at a particular buffer position.A conversion occurs from float to byte.
- Specified by:
putFloat
in classUnsignedBuffer
- Parameters:
index
- the buffer positionvalue
- the float.
-
putDouble
public void putDouble(double value) Description copied from class:UnsignedBuffer
Puts a double at the current buffer position.- Specified by:
putDouble
in classUnsignedBuffer
- Parameters:
value
- the double
-
putDouble
public void putDouble(int index, double value) Description copied from class:UnsignedBuffer
Puts a double at a particular buffer position.- Specified by:
putDouble
in classUnsignedBuffer
- Parameters:
index
- the buffer positionvalue
- the double
-
putLong
public void putLong(long value) Description copied from class:UnsignedBuffer
Puts a long at the current buffer position.- Specified by:
putLong
in classUnsignedBuffer
- Parameters:
value
- the long.
-
array
public final int[] array()The array of the buffer alaIntBuffer.array()
.Unlike
IntBuffer.array()
an array will always be returned, copying it into a newly created array, if it cannot be directly accessed.- Returns:
- the array
-
equals
- Overrides:
equals
in classUnsignedBuffer
-
canEqual
- Overrides:
canEqual
in classUnsignedBuffer
-
hashCode
public int hashCode()- Overrides:
hashCode
in classUnsignedBuffer
-
getDelegate
The underlying storage buffer, to which calls are delegated with our without conversion.
-