Package java.nio

Examples of java.nio.IntBuffer.position()


            /* match input units until there is a full match or the input is consumed */
            for (;;) {
                /* go to the next section */
                int oldpos = toUTable.position();
                toUSection = ((IntBuffer) toUTable.position(index)).slice();
                toUTable.position(oldpos);

                /* read first pair of the section */
                value = toUSection.get();
                length = TO_U_GET_BYTE(value);
View Full Code Here


            /* match input units until there is a full match or the input is consumed */
            for (;;) {
                /* go to the next section */
                int oldpos = toUTable.position();
                toUSection = ((IntBuffer) toUTable.position(index)).slice();
                toUTable.position(oldpos);

                /* read first pair of the section */
                value = toUSection.get();
                length = TO_U_GET_BYTE(value);
                value = TO_U_GET_VALUE(value);
View Full Code Here

    }

    @Test
    public void testAddAllNoBackingArray0() throws Exception {
        IntBuffer buffer = ByteBuffer.allocateDirect(Integer.SIZE / Byte.SIZE * 10).asIntBuffer();
        buffer.position(1).limit(9);
        BoundedIntArray notBackedByArray = BoundedIntArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        notBackedByArray.addAll(IntArray.unsafeValueOf());
        assertEquals(8, notBackedByArray.length());
        assertArrayEquals(new int[]{1, 1, 2, 1, 2, 3, 3, 4}, notBackedByArray.toArray());
View Full Code Here

    }

    @Test
    public void testAddAllNoBackingArray1() throws Exception {
        IntBuffer buffer = ByteBuffer.allocateDirect(Integer.SIZE / Byte.SIZE * 11).asIntBuffer();
        buffer.position(1).limit(9);
        BoundedIntArray notBackedByArray = BoundedIntArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        notBackedByArray.addAll(IntArray.unsafeValueOf(5));
        assertEquals(9, notBackedByArray.length());
        assertArrayEquals(new int[]{1, 1, 2, 1, 2, 3, 3, 4, 5}, notBackedByArray.toArray());
View Full Code Here

    }

    @Test
    public void testAddAllNoBackingArray2() throws Exception {
        IntBuffer buffer = ByteBuffer.allocateDirect(Integer.SIZE / Byte.SIZE * 11).asIntBuffer();
        buffer.position(1).limit(9);
        BoundedIntArray notBackedByArray = BoundedIntArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        notBackedByArray.addAll(IntArray.unsafeValueOf(5, 5));
        assertEquals(10, notBackedByArray.length());
        assertArrayEquals(new int[]{1, 1, 2, 1, 2, 3, 3, 4, 5, 5}, notBackedByArray.toArray());
View Full Code Here

    public BoundedIntArray offset(int offset) {
        int newOffset = elements.position() + offset;
        int newLength = elements.remaining() - offset;
        subArrayCheck(newOffset, newLength);
        IntBuffer copy = elements.duplicate();
        copy.position(newOffset);
        return new SubBoundedIntBufferArrayImpl(this, copy);
    }

    /**
     * <p>Returns a new sub array object for the specified {@code length}. Note that {@code length} must be smaller than
View Full Code Here

        int offset = elements.position();
        int newOffset = offset + fromIndex;
        int newLength = toIndex - fromIndex;
        subArrayCheck(newOffset, newLength);
        IntBuffer copy = elements.duplicate();
        copy.position(newOffset);
        copy.limit(newOffset + newLength);
        return new SubBoundedIntBufferArrayImpl(this, copy);
    }

    /**
 
View Full Code Here

    }

    @Test
    public void testAddAllNoBackingArray0() throws Exception {
        IntBuffer buffer = ByteBuffer.allocateDirect(Integer.SIZE / Byte.SIZE * 10).asIntBuffer();
        buffer.position(1).limit(9);
        BoundedIntArray notBackedByArray = BoundedIntArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        notBackedByArray.addAll(IntArray.unsafeValueOf());
        assertEquals(8, notBackedByArray.length());
        assertArrayEquals(new int[]{1, 1, 2, 1, 2, 3, 3, 4}, notBackedByArray.toArray());
View Full Code Here

    }

    @Test
    public void testAddAllNoBackingArray1() throws Exception {
        IntBuffer buffer = ByteBuffer.allocateDirect(Integer.SIZE / Byte.SIZE * 11).asIntBuffer();
        buffer.position(1).limit(9);
        BoundedIntArray notBackedByArray = BoundedIntArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        notBackedByArray.addAll(IntArray.unsafeValueOf((int) 5));
        assertEquals(9, notBackedByArray.length());
        assertArrayEquals(new int[]{1, 1, 2, 1, 2, 3, 3, 4, 5}, notBackedByArray.toArray());
View Full Code Here

    }

    @Test
    public void testAddAllNoBackingArray2() throws Exception {
        IntBuffer buffer = ByteBuffer.allocateDirect(Integer.SIZE / Byte.SIZE * 11).asIntBuffer();
        buffer.position(1).limit(9);
        BoundedIntArray notBackedByArray = BoundedIntArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        notBackedByArray.addAll(IntArray.unsafeValueOf(5, 5));
        assertEquals(10, notBackedByArray.length());
        assertArrayEquals(new int[]{1, 1, 2, 1, 2, 3, 3, 4, 5, 5}, notBackedByArray.toArray());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.