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 UnsignedIntBufferallocate(int capacity) Allocates a new (direct) buffer of unsigned-ints.final int[]array()The array of the buffer alaIntBuffer.array().protected booleanbooleanThe underlying storage buffer, to which calls are delegated with our without conversion.intgetRaw()Gets an unsigned-int (represented as an int) at the current buffer position.intgetRaw(int index) Gets an unsigned-int (represented as a int) at a particular buffer position.longGets an unsigned-int (represented as a long) at the current buffer position.longgetUnsigned(int index) Gets an unsigned-int (represented as a long) at a particular buffer position.inthashCode()voidputDouble(double value) Puts a double at the current buffer position.voidputDouble(int index, double value) Puts a double at a particular buffer position.voidputFloat(float value) Puts a float at the current buffer position.voidputFloat(int index, float value) Puts a float at a particular buffer position.voidputLong(long value) Puts a long at the current buffer position.voidputRaw(int value) Puts an unsigned-int (represented as a int) at the current buffer position.voidputRaw(int index, int value) Puts an unsigned-int (represented as a int) a particular buffer position.voidputUnsigned(int index, long value) Puts an unsigned-int (represented as a long) a particular buffer position.voidputUnsigned(long value) Puts an unsigned-int (represented by a long) at current buffer position.static UnsignedIntBufferwrapRaw(int[] array) Exposes a raw int-array as a buffer with unsigned-ints.static UnsignedIntBufferExposes a rawUnsignedIntBufferas 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
UnsignedIntBufferthat reusesarrayinternally.
-
wrapRaw
Exposes a rawUnsignedIntBufferas a buffer with unsigned-ints.- Parameters:
bufferRaw- the raw-buffer- Returns:
- a new instance of
UnsignedIntBufferthat reusesbufferRawinternally.
-
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:UnsignedBufferPuts a float at the current buffer position.A conversion occurs from float to short.
- Specified by:
putFloatin classUnsignedBuffer- Parameters:
value- the float.
-
putFloat
public void putFloat(int index, float value) Description copied from class:UnsignedBufferPuts a float at a particular buffer position.A conversion occurs from float to byte.
- Specified by:
putFloatin classUnsignedBuffer- Parameters:
index- the buffer positionvalue- the float.
-
putDouble
public void putDouble(double value) Description copied from class:UnsignedBufferPuts a double at the current buffer position.- Specified by:
putDoublein classUnsignedBuffer- Parameters:
value- the double
-
putDouble
public void putDouble(int index, double value) Description copied from class:UnsignedBufferPuts a double at a particular buffer position.- Specified by:
putDoublein classUnsignedBuffer- Parameters:
index- the buffer positionvalue- the double
-
putLong
public void putLong(long value) Description copied from class:UnsignedBufferPuts a long at the current buffer position.- Specified by:
putLongin 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:
equalsin classUnsignedBuffer
-
canEqual
- Overrides:
canEqualin classUnsignedBuffer
-
hashCode
public int hashCode()- Overrides:
hashCodein classUnsignedBuffer
-
getDelegate
The underlying storage buffer, to which calls are delegated with our without conversion.
-