Class IntPointer

java.lang.Object
org.bytedeco.javacpp.Pointer
org.bytedeco.javacpp.IntPointer
All Implemented Interfaces:
AutoCloseable

@Properties(inherit=javacpp.class) public class IntPointer extends Pointer
The peer class to native pointers and arrays of int, also used for UTF-32. All operations take into account the position and limit, when appropriate.
  • Field Details

    • logger

      private static final Logger logger
  • Constructor Details

    • IntPointer

      public IntPointer(String s)
      Allocates enough memory for encoding the String in UTF-32 and copies it.
      Parameters:
      s - the String to copy
      See Also:
    • IntPointer

      public IntPointer(int... array)
      Allocates enough memory for the array and copies it.
      Parameters:
      array - the array to copy
      See Also:
    • IntPointer

      public IntPointer(IntBuffer buffer)
      For direct buffers, calls Pointer(Buffer), while for buffers backed with an array, allocates enough memory for the array and copies it.
      Parameters:
      buffer - the Buffer to reference or copy
      See Also:
    • IntPointer

      public IntPointer(long size)
      Allocates a native int array of the given size.
      Parameters:
      size - the number of int elements to allocate
    • IntPointer

      public IntPointer()
      See Also:
    • IntPointer

      public IntPointer(Pointer p)
      See Also:
  • Method Details

    • allocateArray

      private void allocateArray(long size)
    • position

      public IntPointer position(long position)
      Description copied from class: Pointer
      Sets the position and returns this. That makes the array.position(i) statement sort of equivalent to the array[i] statement in C++.
      Overrides:
      position in class Pointer
      Parameters:
      position - the new position
      Returns:
      this
      See Also:
    • limit

      public IntPointer limit(long limit)
      Description copied from class: Pointer
      Sets the limit and returns this. Used to limit the size of an operation on this object.
      Overrides:
      limit in class Pointer
      Parameters:
      limit - the new limit
      Returns:
      this
      See Also:
    • capacity

      public IntPointer capacity(long capacity)
      Description copied from class: Pointer
      Sets the capacity and returns this. Should not be called more than once after allocation.
      Overrides:
      capacity in class Pointer
      Parameters:
      capacity - the new capacity
      Returns:
      this
      See Also:
    • sizeof

      public int sizeof()
      Description copied from class: Pointer
      Returns 1 for Pointer or BytePointer else Loader.sizeof(getClass()) or -1 on error.
      Overrides:
      sizeof in class Pointer
    • getPointer

      public IntPointer getPointer(long i)
      Description copied from class: Pointer
      Returns getPointer(getClass(), i).
      Overrides:
      getPointer in class Pointer
    • getStringCodePoints

      public int[] getStringCodePoints()
      Returns the code points, assuming a null-terminated string if limit <= position.
    • getString

      public String getString()
      Returns the String, assuming a null-terminated string if limit <= position.
    • putString

      public IntPointer putString(String s)
      Copies the String code points into native memory, including a terminating null int. Sets the limit to just before the terminating null code point.
      Parameters:
      s - the String to copy
      Returns:
      this
      See Also:
    • get

      public int get()
      Returns:
      get(0)
    • get

      public int get(long i)
      Returns:
      the i-th int value of a native array
    • put

      public IntPointer put(int j)
      Returns:
      put(0, j)
    • put

      public IntPointer put(long i, int j)
      Copies the int value to the i-th element of a native array.
      Parameters:
      i - the index into the array
      j - the int value to copy
      Returns:
      this
    • get

      public IntPointer get(int[] array)
      Returns:
      get(array, 0, array.length)
    • put

      public IntPointer put(int... array)
      Returns:
      put(array, 0, array.length)
    • get

      public IntPointer get(int[] array, int offset, int length)
      Reads a portion of the native array into a Java array.
      Parameters:
      array - the array to write to
      offset - the offset into the array where to start writing
      length - the length of data to read and write
      Returns:
      this
    • put

      public IntPointer put(int[] array, int offset, int length)
      Writes a portion of a Java array into the native array.
      Parameters:
      array - the array to read from
      offset - the offset into the array where to start reading
      length - the length of data to read and write
      Returns:
      this
    • asBuffer

      public final IntBuffer asBuffer()
      Description copied from class: Pointer
      Same as Pointer.asByteBuffer(), but can be overridden to return subclasses of Buffer.
      Overrides:
      asBuffer in class Pointer
      Returns:
      asByteBuffer().asIntBuffer()
      See Also: