Search in sources :

Example 76 with DoubleBuffer

use of java.nio.DoubleBuffer in project es6draft by anba.

the class TypedArrayFunctions method asDoubleBuffer.

private static final DoubleBuffer asDoubleBuffer(ArrayBuffer buffer, int byteOffset, int length) {
    ByteBuffer data = byteBuffer(buffer);
    int byteLength = Double.BYTES * length;
    data.limit(byteOffset + byteLength).position(byteOffset);
    DoubleBuffer view = data.asDoubleBuffer();
    data.clear();
    return view;
}
Also used : DoubleBuffer(java.nio.DoubleBuffer) ByteBuffer(java.nio.ByteBuffer)

Example 77 with DoubleBuffer

use of java.nio.DoubleBuffer in project es6draft by anba.

the class TypedArrayFunctions method asDoubleBuffer.

private static final DoubleBuffer asDoubleBuffer(TypedArrayObject typedArray) {
    ByteBuffer data = byteBuffer(typedArray);
    int byteOffset = byteOffset(typedArray);
    int byteLength = byteLength(typedArray);
    data.limit(byteOffset + byteLength).position(byteOffset);
    DoubleBuffer view = data.asDoubleBuffer();
    data.clear();
    return view;
}
Also used : DoubleBuffer(java.nio.DoubleBuffer) ByteBuffer(java.nio.ByteBuffer)

Example 78 with DoubleBuffer

use of java.nio.DoubleBuffer in project j2objc by google.

the class WrappedDoubleBufferTest method testWrappedDoubleuffer_IllegalArg.

/**
 * @tests java.nio.CharBuffer#allocate(char[],int,int)
 */
public void testWrappedDoubleuffer_IllegalArg() {
    double[] array = new double[20];
    try {
        DoubleBuffer.wrap(array, -1, 0);
        // $NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    try {
        DoubleBuffer.wrap(array, 21, 0);
        // $NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    try {
        DoubleBuffer.wrap(array, 0, -1);
        // $NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    try {
        DoubleBuffer.wrap(array, 0, 21);
        // $NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    try {
        DoubleBuffer.wrap(array, Integer.MAX_VALUE, 1);
        // $NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    try {
        DoubleBuffer.wrap(array, 1, Integer.MAX_VALUE);
        // $NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    try {
        DoubleBuffer.wrap((double[]) null, -1, 0);
        // $NON-NLS-1$
        fail("Should throw NPE");
    } catch (NullPointerException e) {
    }
    DoubleBuffer buf = DoubleBuffer.wrap(array, 2, 16);
    assertEquals(buf.position(), 2);
    assertEquals(buf.limit(), 18);
    assertEquals(buf.capacity(), 20);
}
Also used : DoubleBuffer(java.nio.DoubleBuffer)

Example 79 with DoubleBuffer

use of java.nio.DoubleBuffer in project j2objc by google.

the class ReadOnlyDoubleBufferTest method testPutDoubleBuffer.

public void testPutDoubleBuffer() {
    DoubleBuffer other = DoubleBuffer.allocate(1);
    try {
        buf.put(other);
        // $NON-NLS-1$
        fail("Should throw ReadOnlyBufferException");
    } catch (ReadOnlyBufferException e) {
    // expected
    }
    try {
        buf.put((DoubleBuffer) null);
        // $NON-NLS-1$
        fail("Should throw ReadOnlyBufferException");
    } catch (ReadOnlyBufferException e) {
    // expected
    }
    try {
        buf.put(buf);
        // $NON-NLS-1$
        fail("Should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
    // expected
    }
}
Also used : DoubleBuffer(java.nio.DoubleBuffer) ReadOnlyBufferException(java.nio.ReadOnlyBufferException)

Example 80 with DoubleBuffer

use of java.nio.DoubleBuffer in project j2objc by google.

the class ReadOnlyDoubleBufferTest method testHashCode.

public void testHashCode() {
    DoubleBuffer duplicate = buf.duplicate();
    assertEquals(buf.hashCode(), duplicate.hashCode());
}
Also used : DoubleBuffer(java.nio.DoubleBuffer)

Aggregations

DoubleBuffer (java.nio.DoubleBuffer)162 ByteBuffer (java.nio.ByteBuffer)39 FloatBuffer (java.nio.FloatBuffer)26 IntBuffer (java.nio.IntBuffer)25 ShortBuffer (java.nio.ShortBuffer)22 LongBuffer (java.nio.LongBuffer)14 CharBuffer (java.nio.CharBuffer)11 BufferOverflowException (java.nio.BufferOverflowException)8 IOException (java.io.IOException)5 BufferUnderflowException (java.nio.BufferUnderflowException)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 ServerDenseDoubleRow (com.tencent.angel.ps.impl.matrix.ServerDenseDoubleRow)4 Test (org.junit.Test)4 InvalidMarkException (java.nio.InvalidMarkException)3 Random (java.util.Random)3 BytePointer (org.bytedeco.javacpp.BytePointer)3 DoublePointer (org.bytedeco.javacpp.DoublePointer)3 FloatPointer (org.bytedeco.javacpp.FloatPointer)3 IntPointer (org.bytedeco.javacpp.IntPointer)3