/** * Allocates enough memory for the array and copies it. * * @param array the array to copy * @see #put(Pointer[]) */ public PointerPointer(P ... array) { this(array.length); put(array); } /**
/** * Allocates enough memory for the array of arrays and copies it. * * @param array the array of arrays to copy * @see #put(byte[][]) */ public PointerPointer(byte[] ... array) { this(array.length); put(array); } /**
/** * Allocates enough memory for the array of arrays and copies it. * * @param array the array of arrays to copy * @see #put(float[][]) */ public PointerPointer(float[] ... array) { this(array.length); put(array); } /**
/** * Allocates enough memory for the array of arrays and copies it. * * @param array the array of arrays to copy * @see #put(double[][]) */ public PointerPointer(double[] ... array) { this(array.length); put(array); } /**
/** * Allocates enough memory for the array of arrays and copies it. * * @param array the array of arrays to copy * @see #put(char[][]) */ public PointerPointer(char[] ... array) { this(array.length); put(array); } /**
/** * Allocates enough memory for the array of arrays and copies it. * * @param array the array of arrays to copy * @see #put(int[][]) */ public PointerPointer(int[] ... array) { this(array.length); put(array); } /**
/** * Allocates enough memory for the array of arrays and copies it. * * @param array the array of arrays to copy * @see #put(short[][]) */ public PointerPointer(short[] ... array) { this(array.length); put(array); } /**
/** * Copies the Pointer value to the i-th element of a native array. * * @param i the index into the array * @param p the Pointer value to copy * @return this */ public native PointerPointer<P> put(long i, Pointer p); }
/** * Allocates enough memory for the array of arrays and copies it. * * @param array the array of arrays to copy * @see #put(long[][]) */ public PointerPointer(long[] ... array) { this(array.length); put(array); } /**
/** * Writes the Pointer values into the native {@code void*} array. * * @param array the array of Pointer values to read from * @return this */ public PointerPointer<P> put(P ... array) { pointerArray = array; for (int i = 0; i < array.length; i++) { put(i, array[i]); } return this; } /**
/** * Creates one by one a new {@link BytePointer} for each {@code byte[]}, * and writes them into the native {@code void*} array. * * @param array the array of {@code byte[]} to read from * @return this */ public PointerPointer<P> put(byte[] ... array) { pointerArray = (P[])new BytePointer[array.length]; for (int i = 0; i < array.length; i++) { pointerArray[i] = array[i] != null ? (P)new BytePointer(array[i]) : null; } return put(pointerArray); } /**
/** * Creates one by one a new {@link DoublePointer} for each {@code double[]}, * and writes them into the native {@code void*} array. * * @param array the array of {@code double[]} to read from * @return this */ public PointerPointer<P> put(double[] ... array) { pointerArray = (P[])new DoublePointer[array.length]; for (int i = 0; i < array.length; i++) { pointerArray[i] = array[i] != null ? (P)new DoublePointer(array[i]) : null; } return put(pointerArray); } /**
/** * Creates one by one a new {@link CharPointer} for each {@code char[]}, * and writes them into the native {@code void*} array. * * @param array the array of {@code char[]} to read from * @return this */ public PointerPointer<P> put(char[] ... array) { pointerArray = (P[])new CharPointer[array.length]; for (int i = 0; i < array.length; i++) { pointerArray[i] = array[i] != null ? (P)new CharPointer(array[i]) : null; } return put(pointerArray); }
/** * Creates one by one a new {@link BytePointer} for each {@link String}, * and writes them into the native {@code void*} array. * * @param array the array of {@link String} to read from * @return this */ public PointerPointer<P> putString(String ... array) { pointerArray = (P[])new BytePointer[array.length]; for (int i = 0; i < array.length; i++) { pointerArray[i] = array[i] != null ? (P)new BytePointer(array[i]) : null; } return put(pointerArray); } /**
/** * Creates one by one a new {@link ShortPointer} for each {@code short[]}, * and writes them into the native {@code void*} array. * * @param array the array of {@code short[]} to read from * @return this */ public PointerPointer<P> put(short[] ... array) { pointerArray = (P[])new ShortPointer[array.length]; for (int i = 0; i < array.length; i++) { pointerArray[i] = array[i] != null ? (P)new ShortPointer(array[i]) : null; } return put(pointerArray); } /**
/** * Creates one by one a new {@link BytePointer} for each {@link String}, * and writes them into the native {@code void*} array. * * @param array the array of {@link String} to read from * @param charsetName the charset in which the bytes are encoded * @return this * @throws UnsupportedEncodingException */ public PointerPointer<P> putString(String[] array, String charsetName) throws UnsupportedEncodingException { pointerArray = (P[])new BytePointer[array.length]; for (int i = 0; i < array.length; i++) { pointerArray[i] = array[i] != null ? (P)new BytePointer(array[i], charsetName) : null; } return put(pointerArray); }
/** * Creates one by one a new {@link LongPointer} for each {@code long[]}, * and writes them into the native {@code void*} array. * * @param array the array of {@code long[]} to read from * @return this */ public PointerPointer<P> put(long[] ... array) { pointerArray = (P[])new LongPointer[array.length]; for (int i = 0; i < array.length; i++) { pointerArray[i] = array[i] != null ? (P)new LongPointer(array[i]) : null; } return put(pointerArray); } /**
/** * Creates one by one a new {@link FloatPointer} for each {@code float[]}, * and writes them into the native {@code void*} array. * * @param array the array of {@code float[]} to read from * @return this */ public PointerPointer<P> put(float[] ... array) { pointerArray = (P[])new FloatPointer[array.length]; for (int i = 0; i < array.length; i++) { pointerArray[i] = array[i] != null ? (P)new FloatPointer(array[i]) : null; } return put(pointerArray); } /**
/** * Creates one by one a new {@link IntPointer} for each {@code int[]}, * and writes them into the native {@code void*} array. * * @param array the array of {@code int[]} to read from * @return this */ public PointerPointer<P> put(int[] ... array) { pointerArray = (P[])new IntPointer[array.length]; for (int i = 0; i < array.length; i++) { pointerArray[i] = array[i] != null ? (P)new IntPointer(array[i]) : null; } return put(pointerArray); } /**
@Override public PointerPointer getExtraPointers() { PointerPointer ptr = new PointerPointer(4); CudaContext context = (CudaContext) AtomicAllocator.getInstance().getDeviceContext().getContext(); ptr.put(0, AtomicAllocator.getInstance().getHostPointer(stateBuffer)); ptr.put(1, context.getOldStream()); return ptr; } }