/** * Returns a {@link FloatBuffer} which reads and writes to the same memory * location pointed to by this {@link MachineSizedFloatPtr}. Must only be * called on 32-bit platforms. * * @param n the maximum number of floats the {@link FloatBuffer} can * read/write. This will be the {@link FloatBuffer}'s * <code>capacity</code>. * @return the {@link FloatBuffer}. * @throws IllegalStateException if this isn't a 32-bit platform. */ public FloatBuffer asFloatBuffer(int n) { if (_sizeOf() != 4) { throw new IllegalStateException("Not a 32-bit platform"); } return VM.newDirectByteBuffer(getHandle(), n << 2) .order(ByteOrder.nativeOrder()).asFloatBuffer(); }
/** * Returns a {@link DoubleBuffer} which reads and writes to the same memory * location pointed to by this {@link MachineSizedFloatPtr}. Must only be * called on 64-bit platforms. * * @param n the maximum number of doubles the {@link DoubleBuffer} can * read/write. This will be the {@link DoubleBuffer}'s * <code>capacity</code>. * @return the {@link DoubleBuffer}. * @throws IllegalStateException if this isn't a 64-bit platform. */ public DoubleBuffer asDoubleBuffer(int n) { if (_sizeOf() != 8) { throw new IllegalStateException("Not a 64-bit platform"); } return VM.newDirectByteBuffer(getHandle(), n << 3) .order(ByteOrder.nativeOrder()).asDoubleBuffer(); }
/** * Copies {@code count} floats from the memory pointed to by this * {@link MachineSizedFloatPtr} to {@code dst} starting at offset {@code offset}. * Does {@code double} to {@code float} conversion if running on * a 64-bit platform. * * @param dst the destination. * @param offset the offset within the destination array to start copying to. * @param count the number of elements to copy. */ public void get(float[] dst, int offset, int count) { if (_sizeOf() == 4) { asFloatBuffer(count).get(dst, offset, count); } else { Arrays.checkOffsetAndCount(dst.length, offset, count); DoubleBuffer buf = asDoubleBuffer(count); for (int i = 0; i < count; i++) { dst[i + offset] = (float) buf.get(); } } }
/** * Copies {@code count} doubles from the memory pointed to by this * {@link MachineSizedFloatPtr} to {@code dst} starting at offset {@code offset}. * Does {@code float} to {@code double} conversion if running on * a 32-bit platform. * * @param dst the destination. * @param offset the offset within the destination array to start copying to. * @param count the number of elements to copy. */ public void get(double[] dst, int offset, int count) { if (_sizeOf() == 8) { asDoubleBuffer(count).get(dst, offset, count); } else { Arrays.checkOffsetAndCount(dst.length, offset, count); FloatBuffer buf = asFloatBuffer(count); for (int i = 0; i < count; i++) { dst[i + offset] = buf.get(); } } }
/** * Copies {@code count} doubles from {@code src} starting at offset {@code offset} * to the memory pointed to by this {@link MachineSizedFloatPtr}. Does * {@code double} to {@code float} conversion if running on a 32-bit * platform. * * @param src the source. * @param offset the offset within the source array to start copying from. * @param count the number of elements to copy. */ public void set(double[] src, int offset, int count) { if (_sizeOf() == 4) { asDoubleBuffer(count).put(src, offset, count); } else { Arrays.checkOffsetAndCount(src.length, offset, count); FloatBuffer buf = asFloatBuffer(count); for (int i = 0; i < count; i++) { buf.put((float) src[i + offset]); } } } }
/** * Copies {@code count} floats from {@code src} starting at offset {@code offset} * to the memory pointed to by this {@link MachineSizedFloatPtr}. Does * {@code float} to {@code double} conversion if running on a 64-bit * platform. * * @param src the source. * @param offset the offset within the source array to start copying from. * @param count the number of elements to copy. */ public void set(float[] src, int offset, int count) { if (_sizeOf() == 4) { asFloatBuffer(count).put(src, offset, count); } else { Arrays.checkOffsetAndCount(src.length, offset, count); DoubleBuffer buf = asDoubleBuffer(count); for (int i = 0; i < count; i++) { buf.put(src[i + offset]); } } }
/** * Returns a {@link DoubleBuffer} which reads and writes to the same memory * location pointed to by this {@link MachineSizedFloatPtr}. Must only be * called on 64-bit platforms. * * @param n the maximum number of doubles the {@link DoubleBuffer} can * read/write. This will be the {@link DoubleBuffer}'s * <code>capacity</code>. * @return the {@link DoubleBuffer}. * @throws IllegalStateException if this isn't a 64-bit platform. */ public DoubleBuffer asDoubleBuffer(int n) { if (_sizeOf() != 8) { throw new IllegalStateException("Not a 64-bit platform"); } return VM.newDirectByteBuffer(getHandle(), n << 3) .order(ByteOrder.nativeOrder()).asDoubleBuffer(); }
/** * Returns a {@link FloatBuffer} which reads and writes to the same memory * location pointed to by this {@link MachineSizedFloatPtr}. Must only be * called on 32-bit platforms. * * @param n the maximum number of floats the {@link FloatBuffer} can * read/write. This will be the {@link FloatBuffer}'s * <code>capacity</code>. * @return the {@link FloatBuffer}. * @throws IllegalStateException if this isn't a 32-bit platform. */ public FloatBuffer asFloatBuffer(int n) { if (_sizeOf() != 4) { throw new IllegalStateException("Not a 32-bit platform"); } return VM.newDirectByteBuffer(getHandle(), n << 2) .order(ByteOrder.nativeOrder()).asFloatBuffer(); }
/** * Returns a {@link FloatBuffer} which reads and writes to the same memory * location pointed to by this {@link MachineSizedFloatPtr}. Must only be * called on 32-bit platforms. * * @param n the maximum number of floats the {@link FloatBuffer} can * read/write. This will be the {@link FloatBuffer}'s * <code>capacity</code>. * @return the {@link FloatBuffer}. * @throws IllegalStateException if this isn't a 32-bit platform. */ public FloatBuffer asFloatBuffer(int n) { if (_sizeOf() != 4) { throw new IllegalStateException("Not a 32-bit platform"); } return VM.newDirectByteBuffer(getHandle(), n << 2) .order(ByteOrder.nativeOrder()).asFloatBuffer(); }
/** * Returns a {@link DoubleBuffer} which reads and writes to the same memory * location pointed to by this {@link MachineSizedFloatPtr}. Must only be * called on 64-bit platforms. * * @param n the maximum number of doubles the {@link DoubleBuffer} can * read/write. This will be the {@link DoubleBuffer}'s * <code>capacity</code>. * @return the {@link DoubleBuffer}. * @throws IllegalStateException if this isn't a 64-bit platform. */ public DoubleBuffer asDoubleBuffer(int n) { if (_sizeOf() != 8) { throw new IllegalStateException("Not a 64-bit platform"); } return VM.newDirectByteBuffer(getHandle(), n << 3) .order(ByteOrder.nativeOrder()).asDoubleBuffer(); }
/** * Returns a {@link FloatBuffer} which reads and writes to the same memory * location pointed to by this {@link MachineSizedFloatPtr}. Must only be * called on 32-bit platforms. * * @param n the maximum number of floats the {@link FloatBuffer} can * read/write. This will be the {@link FloatBuffer}'s * <code>capacity</code>. * @return the {@link FloatBuffer}. * @throws IllegalStateException if this isn't a 32-bit platform. */ public FloatBuffer asFloatBuffer(int n) { if (_sizeOf() != 4) { throw new IllegalStateException("Not a 32-bit platform"); } return VM.newDirectByteBuffer(getHandle(), n << 2) .order(ByteOrder.nativeOrder()).asFloatBuffer(); }
/** * Returns a {@link DoubleBuffer} which reads and writes to the same memory * location pointed to by this {@link MachineSizedFloatPtr}. Must only be * called on 64-bit platforms. * * @param n the maximum number of doubles the {@link DoubleBuffer} can * read/write. This will be the {@link DoubleBuffer}'s * <code>capacity</code>. * @return the {@link DoubleBuffer}. * @throws IllegalStateException if this isn't a 64-bit platform. */ public DoubleBuffer asDoubleBuffer(int n) { if (_sizeOf() != 8) { throw new IllegalStateException("Not a 64-bit platform"); } return VM.newDirectByteBuffer(getHandle(), n << 3) .order(ByteOrder.nativeOrder()).asDoubleBuffer(); }
/** * Returns a {@link FloatBuffer} which reads and writes to the same memory * location pointed to by this {@link MachineSizedFloatPtr}. Must only be * called on 32-bit platforms. * * @param n the maximum number of floats the {@link FloatBuffer} can * read/write. This will be the {@link FloatBuffer}'s * <code>capacity</code>. * @return the {@link FloatBuffer}. * @throws IllegalStateException if this isn't a 32-bit platform. */ public FloatBuffer asFloatBuffer(int n) { if (_sizeOf() != 4) { throw new IllegalStateException("Not a 32-bit platform"); } return VM.newDirectByteBuffer(getHandle(), n << 2) .order(ByteOrder.nativeOrder()).asFloatBuffer(); }
/** * Returns a {@link DoubleBuffer} which reads and writes to the same memory * location pointed to by this {@link MachineSizedFloatPtr}. Must only be * called on 64-bit platforms. * * @param n the maximum number of doubles the {@link DoubleBuffer} can * read/write. This will be the {@link DoubleBuffer}'s * <code>capacity</code>. * @return the {@link DoubleBuffer}. * @throws IllegalStateException if this isn't a 64-bit platform. */ public DoubleBuffer asDoubleBuffer(int n) { if (_sizeOf() != 8) { throw new IllegalStateException("Not a 64-bit platform"); } return VM.newDirectByteBuffer(getHandle(), n << 3) .order(ByteOrder.nativeOrder()).asDoubleBuffer(); }
/** * Copies {@code count} floats from the memory pointed to by this * {@link MachineSizedFloatPtr} to {@code dst} starting at offset {@code offset}. * Does {@code double} to {@code float} conversion if running on * a 64-bit platform. * * @param dst the destination. * @param offset the offset within the destination array to start copying to. * @param count the number of elements to copy. */ public void get(float[] dst, int offset, int count) { if (_sizeOf() == 4) { asFloatBuffer(count).get(dst, offset, count); } else { Arrays.checkOffsetAndCount(dst.length, offset, count); DoubleBuffer buf = asDoubleBuffer(count); for (int i = 0; i < count; i++) { dst[i + offset] = (float) buf.get(); } } }
/** * Copies {@code count} doubles from the memory pointed to by this * {@link MachineSizedFloatPtr} to {@code dst} starting at offset {@code offset}. * Does {@code float} to {@code double} conversion if running on * a 32-bit platform. * * @param dst the destination. * @param offset the offset within the destination array to start copying to. * @param count the number of elements to copy. */ public void get(double[] dst, int offset, int count) { if (_sizeOf() == 8) { asDoubleBuffer(count).get(dst, offset, count); } else { Arrays.checkOffsetAndCount(dst.length, offset, count); FloatBuffer buf = asFloatBuffer(count); for (int i = 0; i < count; i++) { dst[i + offset] = buf.get(); } } }
/** * Copies {@code count} doubles from the memory pointed to by this * {@link MachineSizedFloatPtr} to {@code dst} starting at offset {@code offset}. * Does {@code float} to {@code double} conversion if running on * a 32-bit platform. * * @param dst the destination. * @param offset the offset within the destination array to start copying to. * @param count the number of elements to copy. */ public void get(double[] dst, int offset, int count) { if (_sizeOf() == 8) { asDoubleBuffer(count).get(dst, offset, count); } else { Arrays.checkOffsetAndCount(dst.length, offset, count); FloatBuffer buf = asFloatBuffer(count); for (int i = 0; i < count; i++) { dst[i + offset] = buf.get(); } } }
/** * Copies {@code count} doubles from {@code src} starting at offset {@code offset} * to the memory pointed to by this {@link MachineSizedFloatPtr}. Does * {@code double} to {@code float} conversion if running on a 32-bit * platform. * * @param src the source. * @param offset the offset within the source array to start copying from. * @param count the number of elements to copy. */ public void set(double[] src, int offset, int count) { if (_sizeOf() == 4) { asDoubleBuffer(count).put(src, offset, count); } else { Arrays.checkOffsetAndCount(src.length, offset, count); FloatBuffer buf = asFloatBuffer(count); for (int i = 0; i < count; i++) { buf.put((float) src[i + offset]); } } } }
/** * Copies {@code count} floats from {@code src} starting at offset {@code offset} * to the memory pointed to by this {@link MachineSizedFloatPtr}. Does * {@code float} to {@code double} conversion if running on a 64-bit * platform. * * @param src the source. * @param offset the offset within the source array to start copying from. * @param count the number of elements to copy. */ public void set(float[] src, int offset, int count) { if (_sizeOf() == 4) { asFloatBuffer(count).put(src, offset, count); } else { Arrays.checkOffsetAndCount(src.length, offset, count); DoubleBuffer buf = asDoubleBuffer(count); for (int i = 0; i < count; i++) { buf.put(src[i + offset]); } } }
/** * Copies {@code count} floats from {@code src} starting at offset {@code offset} * to the memory pointed to by this {@link MachineSizedFloatPtr}. Does * {@code float} to {@code double} conversion if running on a 64-bit * platform. * * @param src the source. * @param offset the offset within the source array to start copying from. * @param count the number of elements to copy. */ public void set(float[] src, int offset, int count) { if (_sizeOf() == 4) { asFloatBuffer(count).put(src, offset, count); } else { Arrays.checkOffsetAndCount(src.length, offset, count); DoubleBuffer buf = asDoubleBuffer(count); for (int i = 0; i < count; i++) { buf.put(src[i + offset]); } } }