Package java.nio

Examples of java.nio.DoubleBuffer


        assertArrayEquals(new double[]{1, 1, 2, 1, 2, 3, 3, 4}, notBackedByArray.toArray(), 0);
    }

    @Test
    public void testAddAllNoBackingArray1() throws Exception {
        DoubleBuffer buffer = ByteBuffer.allocateDirect(Double.SIZE / Byte.SIZE * 11).asDoubleBuffer();
        buffer.position(1).limit(9);
        BoundedDoubleArray notBackedByArray = BoundedDoubleArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        notBackedByArray.addAll(DoubleArray.unsafeValueOf((double) 5));
        assertEquals(9, notBackedByArray.length());
        assertArrayEquals(new double[]{1, 1, 2, 1, 2, 3, 3, 4, 5}, notBackedByArray.toArray(), 0);
View Full Code Here


        assertArrayEquals(new double[]{1, 1, 2, 1, 2, 3, 3, 4, 5}, notBackedByArray.toArray(), 0);
    }

    @Test
    public void testAddAllNoBackingArray2() throws Exception {
        DoubleBuffer buffer = ByteBuffer.allocateDirect(Double.SIZE / Byte.SIZE * 11).asDoubleBuffer();
        buffer.position(1).limit(9);
        BoundedDoubleArray notBackedByArray = BoundedDoubleArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        notBackedByArray.addAll(DoubleArray.unsafeValueOf((double) 5, (double) 5));
        assertEquals(10, notBackedByArray.length());
        assertArrayEquals(new double[]{1, 1, 2, 1, 2, 3, 3, 4, 5, 5}, notBackedByArray.toArray(), 0);
View Full Code Here

        assertArrayEquals(new double[]{1, 1, 2, 1, 2, 3, 3, 4, 5, 5}, notBackedByArray.toArray(), 0);
    }

    @Test
    public void testAddAllNoBackingArray3() throws Exception {
        DoubleBuffer buffer = ByteBuffer.allocateDirect(Double.SIZE / Byte.SIZE * 11).asDoubleBuffer();
        buffer.position(1).limit(9);
        BoundedDoubleArray notBackedByArray = BoundedDoubleArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        try {
            notBackedByArray.addAll(DoubleArray.unsafeValueOf((double) 5, (double) 5, (double) 5));
            fail();
View Full Code Here

        int offset = array.offset();
        array.setAll(DoubleArray.unsafeValueOf());
        assertArrayEquals(new double[]{}, array.toArray(), 0);
        assertEquals(0, array.length());
        assertEquals(offset, array.offset());
        DoubleBuffer buffer = array.buffer();
        buffer.rewind().limit(buffer.capacity());
        while (buffer.hasRemaining()) {
            assertEquals(0, buffer.get(), 0);
        }
    }
View Full Code Here

            array.doubleRemove();
        }
        assertArrayEquals(new double[]{}, array.toArray(), 0);
        assertEquals(0, array.length());
        assertEquals(offset, array.offset());
        DoubleBuffer buffer = array.buffer();
        buffer.rewind().limit(buffer.capacity());
        while (buffer.hasRemaining()) {
            assertEquals(0, buffer.get(), 0);
        }
    }
View Full Code Here

        int offset = array.offset();
        array.clear();
        assertArrayEquals(new double[]{}, array.toArray(), 0);
        assertEquals(0, array.length());
        assertEquals(offset, array.offset());
        DoubleBuffer buffer = array.buffer();
        buffer.rewind().limit(buffer.capacity());
        while (buffer.hasRemaining()) {
            assertEquals(0, buffer.get(), 0);
        }
    }
View Full Code Here

    @Override
    public BoundedDoubleArray offset(int offset) {
        int newOffset = elements.position() + offset;
        int newLength = elements.remaining() - offset;
        subArrayCheck(newOffset, newLength);
        DoubleBuffer copy = elements.duplicate();
        copy.position(newOffset);
        return new SubBoundedDoubleBufferArrayImpl(this, copy);
    }
View Full Code Here

     */
    @Override
    public MutableDoubleArray length(int length) {
        int offset = elements.position();
        subArrayCheck(offset, length);
        DoubleBuffer copy = elements.duplicate();
        copy.limit(offset + length);
        return new SubBoundedDoubleBufferArrayImpl(this, copy);
    }
View Full Code Here

    public MutableDoubleArray subArray(int fromIndex, int toIndex) {
        int offset = elements.position();
        int newOffset = offset + fromIndex;
        int newLength = toIndex - fromIndex;
        subArrayCheck(newOffset, newLength);
        DoubleBuffer copy = elements.duplicate();
        copy.position(newOffset);
        copy.limit(newOffset + newLength);
        return new SubBoundedDoubleBufferArrayImpl(this, copy);
    }
View Full Code Here

            return this;
        }
        int newOffset = elements.position() + offset;
        int newLength = elements.remaining() - offset;
        subArrayCheck(newOffset, newLength);
        DoubleBuffer copy = elements.duplicate();
        copy.position(newOffset);
        return new SubMutableDoubleBufferArrayImpl(this, copy);
    }
View Full Code Here

TOP

Related Classes of java.nio.DoubleBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.