Class MachineSizedFloatPtr

All Implemented Interfaces:
Iterable<MachineSizedFloatPtr>

public final class MachineSizedFloatPtr
extends Struct<MachineSizedFloatPtr>
Points to either a float or double value depending on the machine word.
  • Constructor Details

    • MachineSizedFloatPtr

      public MachineSizedFloatPtr()
      Creates a new MachineSizedFloatPtr with a value of 0.0.
  • Method Details

    • get

      public double get()
      Returns the current value.
      Returns:
      the value.
    • set

      public void set​(double value)
      Sets the value.
      Parameters:
      value - the new value.
    • asFloatBuffer

      public FloatBuffer asFloatBuffer​(int n)
      Returns a FloatBuffer which reads and writes to the same memory location pointed to by this MachineSizedFloatPtr. Must only be called on 32-bit platforms.
      Parameters:
      n - the maximum number of floats the FloatBuffer can read/write. This will be the FloatBuffer's capacity.
      Returns:
      the FloatBuffer.
      Throws:
      IllegalStateException - if this isn't a 32-bit platform.
    • asDoubleBuffer

      public DoubleBuffer asDoubleBuffer​(int n)
      Returns a DoubleBuffer which reads and writes to the same memory location pointed to by this MachineSizedFloatPtr. Must only be called on 64-bit platforms.
      Parameters:
      n - the maximum number of doubles the DoubleBuffer can read/write. This will be the DoubleBuffer's capacity.
      Returns:
      the DoubleBuffer.
      Throws:
      IllegalStateException - if this isn't a 64-bit platform.
    • toFloatArray

      public float[] toFloatArray​(int n)
      Copies n floats from the memory pointed to by this MachineSizedFloatPtr to a new float[] instance. Does double to float conversion if running on a 64-bit platform.
      Parameters:
      n - the number of floats to copy.
      Returns:
      the float[].
    • get

      public void get​(float[] dst)
      Copies dst.length floats from the memory pointed to by this MachineSizedFloatPtr to dst. Does double to float conversion if running on a 64-bit platform.
      Parameters:
      dst - the destination.
    • get

      public void get​(float[] dst, int offset, int count)
      Copies count floats from the memory pointed to by this MachineSizedFloatPtr to dst starting at offset offset. Does double to float conversion if running on a 64-bit platform.
      Parameters:
      dst - the destination.
      offset - the offset within the destination array to start copying to.
      count - the number of elements to copy.
    • set

      public void set​(float[] src)
      Copies src.length floats from src to the memory pointed to by this MachineSizedFloatPtr. Does float to double conversion if running on a 64-bit platform.
      Parameters:
      src - the source.
    • set

      public void set​(float[] src, int offset, int count)
      Copies count floats from src starting at offset offset to the memory pointed to by this MachineSizedFloatPtr. Does float to double conversion if running on a 64-bit platform.
      Parameters:
      src - the source.
      offset - the offset within the source array to start copying from.
      count - the number of elements to copy.
    • toDoubleArray

      public double[] toDoubleArray​(int n)
      Copies n doubles from the memory pointed to by this MachineSizedFloatPtr to a new double[] instance. Does float to double conversion if running on a 32-bit platform.
      Parameters:
      n - the number of doubles to copy.
      Returns:
      the float[].
    • get

      public void get​(double[] dst)
      Copies dst.length doubles from the memory pointed to by this MachineSizedFloatPtr to dst. Does float to double conversion if running on a 32-bit platform.
      Parameters:
      dst - the destination.
    • get

      public void get​(double[] dst, int offset, int count)
      Copies count doubles from the memory pointed to by this MachineSizedFloatPtr to dst starting at offset offset. Does float to double conversion if running on a 32-bit platform.
      Parameters:
      dst - the destination.
      offset - the offset within the destination array to start copying to.
      count - the number of elements to copy.
    • set

      public void set​(double[] src)
      Copies src.length doubles from src to the memory pointed to by this MachineSizedFloatPtr. Does double to float conversion if running on a 32-bit platform.
      Parameters:
      src - the source.
    • set

      public void set​(double[] src, int offset, int count)
      Copies count doubles from src starting at offset offset to the memory pointed to by this MachineSizedFloatPtr. Does double to float conversion if running on a 32-bit platform.
      Parameters:
      src - the source.
      offset - the offset within the source array to start copying from.
      count - the number of elements to copy.