Class UnsignedIntBuffer

Object
UnsignedBuffer
UnsignedIntBuffer

public final class UnsignedIntBuffer extends UnsignedBuffer
Wraps an 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 Type
    Method
    Description
    allocate(int capacity)
    Allocates a new (direct) buffer of unsigned-ints.
    final int[]
    The array of the buffer ala IntBuffer.array().
    protected boolean
     
    boolean
     
    The underlying storage buffer, to which calls are delegated with our without conversion.
    int
    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
     
    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.
    wrapRaw(int[] array)
    Exposes a raw int-array as a buffer with unsigned-ints.
    wrapRaw(IntBuffer bufferRaw)
    Exposes a raw UnsignedIntBuffer as a buffer with unsigned-ints.

    Methods inherited from class org.anchoranalysis.image.voxel.buffer.primitive.UnsignedBuffer

    capacity, clear, hasArray, hasRemaining, isDirect, position, position

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • allocate

      public static UnsignedIntBuffer allocate(int capacity)
      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

      public static UnsignedIntBuffer wrapRaw(int[] array)
      Exposes a raw int-array as a buffer with unsigned-ints.
      Parameters:
      array - the int-array
      Returns:
      a new instance of UnsignedIntBuffer that reuses array internally.
    • wrapRaw

      public static UnsignedIntBuffer wrapRaw(IntBuffer bufferRaw)
      Exposes a raw UnsignedIntBuffer as a buffer with unsigned-ints.
      Parameters:
      bufferRaw - the raw-buffer
      Returns:
      a new instance of UnsignedIntBuffer that reuses bufferRaw 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 position
      value - 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 position
      value - 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 class UnsignedBuffer
      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 class UnsignedBuffer
      Parameters:
      index - the buffer position
      value - 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 class UnsignedBuffer
      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 class UnsignedBuffer
      Parameters:
      index - the buffer position
      value - 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 class UnsignedBuffer
      Parameters:
      value - the long.
    • array

      public final int[] array()
      The array of the buffer ala IntBuffer.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

      public boolean equals(Object o)
      Overrides:
      equals in class UnsignedBuffer
    • canEqual

      protected boolean canEqual(Object other)
      Overrides:
      canEqual in class UnsignedBuffer
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class UnsignedBuffer
    • getDelegate

      public IntBuffer getDelegate()
      The underlying storage buffer, to which calls are delegated with our without conversion.