Package java.nio

Examples of java.nio.IntBuffer.position()


    }

    @Test
    public void testAddAllNoBackingArray3() 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);
        try {
            notBackedByArray.addAll(IntArray.unsafeValueOf(5, 5, 5));
            fail();
View Full Code Here


        }
        int newOffset = elements.position() + offset;
        int newLength = elements.remaining() - offset;
        subArrayCheck(newOffset, newLength);
        IntBuffer copy = elements.duplicate();
        copy.position(newOffset);
        return new IntBufferArrayImpl(copy, characteristics, false);
    }

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

        if (newOffset == offset && newLength == length) {
            return this;
        }
        subArrayCheck(newOffset, newLength);
        IntBuffer copy = elements.duplicate();
        copy.position(newOffset);
        copy.limit(newOffset + newLength);
        return new IntBufferArrayImpl(copy, characteristics, false);
    }

    @SuppressWarnings({"MissingMethodJavaDoc", "MissingFieldJavaDoc"})
View Full Code Here

        if (newOffset == offset && newLength == length) {
            return this;
        }
        subArrayCheck(newOffset, newLength);
        IntBuffer copy = elements.duplicate();
        copy.position(newOffset);
        copy.limit(newOffset + newLength);
        return new SubMutableIntBufferArrayImpl(this, copy);
    }

    @SuppressWarnings({"MissingMethodJavaDoc", "MissingFieldJavaDoc"})
View Full Code Here

    private IntList getEntryInternal(int idx) {
        int offset = offsets[idx];
        int size = sizes[idx];
        IntBuffer buf = buffer.duplicate();
        buf.position(offset).limit(offset + size);
        return BufferBackedIntList.create(buf);
    }

    public Collection<Pair<Long,IntList>> entries() {
        return new EntryCollection();
View Full Code Here

        // readonly's contents should be the same as buf
        IntBuffer readonly = buf.asReadOnlyBuffer();
        assertNotSame(buf, readonly);
        assertTrue(readonly.isReadOnly());
        assertEquals(buf.position(), readonly.position());
        assertEquals(buf.limit(), readonly.limit());
        assertEquals(buf.isDirect(), readonly.isDirect());
        assertEquals(buf.order(), readonly.order());
        assertContentEquals(buf, readonly);
View Full Code Here

        assertEquals(buf.order(), readonly.order());
        assertContentEquals(buf, readonly);

        // readonly's position, mark, and limit should be independent to buf
        readonly.reset();
        assertEquals(readonly.position(), 0);
        readonly.clear();
        assertEquals(buf.position(), buf.limit());
        buf.reset();
        assertEquals(buf.position(), 0);
    }
View Full Code Here

        assertEquals(0, buf.compareTo(other));
        assertEquals(0, other.compareTo(buf));
        buf.position(1);
        assertTrue(buf.compareTo(other) > 0);
        assertTrue(other.compareTo(buf) < 0);
        other.position(2);
        assertTrue(buf.compareTo(other) < 0);
        assertTrue(other.compareTo(buf) > 0);
        buf.position(2);
        other.limit(5);
        assertTrue(buf.compareTo(other) > 0);
View Full Code Here

        buf.position(buf.limit());

        // duplicate's contents should be the same as buf
        IntBuffer duplicate = buf.duplicate();
        assertNotSame(buf, duplicate);
        assertEquals(buf.position(), duplicate.position());
        assertEquals(buf.limit(), duplicate.limit());
        assertEquals(buf.isReadOnly(), duplicate.isReadOnly());
        assertEquals(buf.isDirect(), duplicate.isDirect());
        assertEquals(buf.order(), duplicate.order());
        assertContentEquals(buf, duplicate);
View Full Code Here

        assertEquals(buf.order(), duplicate.order());
        assertContentEquals(buf, duplicate);

        // duplicate's position, mark, and limit should be independent to buf
        duplicate.reset();
        assertEquals(duplicate.position(), 0);
        duplicate.clear();
        assertEquals(buf.position(), buf.limit());
        buf.reset();
        assertEquals(buf.position(), 0);
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.