Class MachineSizedSIntPtr

All Implemented Interfaces:
Iterable<MachineSizedSIntPtr>

public final class MachineSizedSIntPtr
extends Struct<MachineSizedSIntPtr>
Points to a 32-bit or 64-bit signed value depending on the machine word size (long * in C).
  • Constructor Details

    • MachineSizedSIntPtr

      public MachineSizedSIntPtr()
      Creates a new MachineSizedSIntPtr with a value of 0.
  • Method Details

    • get

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

      public void set​(long value)
      Sets the value.
      Parameters:
      value - the new value.
    • asIntBuffer

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

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

      public int[] toIntArray​(int n)
      Copies n ints from the memory pointed to by this MachineSizedSIntPtr to a new int[] instance. Does the proper narrowing long to int conversion if running on a 64-bit platform.
      Parameters:
      n - the number of ints to copy.
      Returns:
      the int[].
    • get

      public void get​(int[] dst)
      Copies dst.length ints from the memory pointed to by this MachineSizedSIntPtr to dst. Does the proper narrowing long to int conversion if running on a 64-bit platform.
      Parameters:
      dst - the destination.
    • get

      public void get​(int[] dst, int offset, int count)
      Copies count ints from the memory pointed to by this MachineSizedSIntPtr to dst starting at offset offset. Does the proper narrowing long to int 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​(int[] src)
      Copies src.length ints from src to the memory pointed to by this MachineSizedSIntPtr. Does signed int to long conversion if running on a 64-bit platform.
      Parameters:
      src - the source.
    • set

      public void set​(int[] src, int offset, int count)
      Copies count ints from src starting at offset offset to the memory pointed to by this MachineSizedSIntPtr. Does signed int to long 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.
    • toLongArray

      public long[] toLongArray​(int n)
      Copies n longs from the memory pointed to by this MachineSizedSIntPtr to a new long[] instance. Does signed int to long conversion if running on a 32-bit platform.
      Parameters:
      n - the number of longs to copy.
      Returns:
      the long[].
    • get

      public void get​(long[] dst)
      Copies dst.length longs from the memory pointed to by this MachineSizedSIntPtr to dst. Does signed int to long conversion if running on a 32-bit platform.
      Parameters:
      dst - the destination.
    • get

      public void get​(long[] dst, int offset, int count)
      Copies count longs from the memory pointed to by this MachineSizedSIntPtr to dst starting at offset offset. Does signed int to long 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​(long[] src)
      Copies src.length longs from src to the memory pointed to by this MachineSizedSIntPtr. Does the proper narrowing long to int conversion if running on a 32-bit platform.
      Parameters:
      src - the source.
    • set

      public void set​(long[] src, int offset, int count)
      Copies count longs from src starting at offset offset to the memory pointed to by this MachineSizedSIntPtr. Does the proper narrowing long to int 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.