Class ShortPointer

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    @Properties(inherit=javacpp.class)
    public class ShortPointer
    extends Pointer
    The peer class to native pointers and arrays of short. All operations take into account the position and limit, when appropriate.
    • Field Detail

      • logger

        private static final Logger logger
    • Constructor Detail

      • ShortPointer

        public ShortPointer​(short... array)
        Allocates enough memory for the array and copies it.
        Parameters:
        array - the array to copy
        See Also:
        put(short[])
      • ShortPointer

        public ShortPointer​(java.nio.ShortBuffer 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:
        put(short[])
      • ShortPointer

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

        public ShortPointer()
        See Also:
        Pointer()
    • Method Detail

      • allocateArray

        private void allocateArray​(long size)
      • position

        public ShortPointer 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:
        Pointer.position(long)
      • limit

        public ShortPointer 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:
        Pointer.limit(long)
      • capacity

        public ShortPointer 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:
        Pointer.capacity(long)
      • 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
      • get

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

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

        public ShortPointer put​(short s)
        Returns:
        put(0, s)
      • put

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

        public ShortPointer get​(short[] array)
        Returns:
        get(array, 0, array.length)
      • put

        public ShortPointer put​(short... array)
        Returns:
        put(array, 0, array.length)
      • get

        public ShortPointer get​(short[] 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 ShortPointer put​(short[] 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