Package it.unimi.dsi.fastutil.ints

Examples of it.unimi.dsi.fastutil.ints.IntList


    @Test
    public void testSingletonBuffer() {
        ByteBuffer buf = ByteBuffer.allocate(4);
        buf.putInt(42);
        buf.flip();
        IntList list = BufferBackedIntList.create(buf.asIntBuffer());
        assertThat(list, hasSize(1));
        assertThat(list, contains(42));
    }
View Full Code Here


        ByteBuffer buf = ByteBuffer.allocate(32);
        for (int i = 0; i < 5; i++) {
            buf.putInt(i);
        }
        buf.flip();
        IntList list = BufferBackedIntList.create(buf.asIntBuffer());
        assertThat(list, hasSize(5));
        assertThat(list, contains(0, 1, 2, 3, 4));
    }
View Full Code Here

*/
public class IntIntervalListTest {

    @Test
    public void testEmptyList() {
        IntList list = new IntIntervalList(0);
        assertTrue(list.isEmpty());
        assertEquals(0, list.size());
        assertFalse(list.iterator().hasNext());
    }
View Full Code Here

        assertFalse(list.iterator().hasNext());
    }

    @Test
    public void testEmptyRange() {
        IntList list = new IntIntervalList(5, 5);
        assertTrue(list.isEmpty());
        assertEquals(0, list.size());
        assertFalse(list.iterator().hasNext());
    }
View Full Code Here

        assertFalse(list.iterator().hasNext());
    }

    @Test
    public void testSimpleListAccess() {
        IntList list = new IntIntervalList(1);
        assertFalse(list.isEmpty());
        assertEquals(1, list.size());
        assertEquals(0, list.getInt(0));
        try {
            list.getInt(1);
            fail("getInt(1) should throw");
        } catch (IndexOutOfBoundsException e) {
            /* no-op */
        }
        IntListIterator iter = list.iterator();
        assertTrue(iter.hasNext());
        assertFalse(iter.hasPrevious());
        assertEquals(0, iter.nextInt());
        assertFalse(iter.hasNext());
        assertTrue(iter.hasPrevious());
View Full Code Here

        assertEquals(0, iter.previousInt());
    }

    @Test
    public void testSimpleIntervalAccess() {
        IntList list = new IntIntervalList(42, 43);
        assertFalse(list.isEmpty());
        assertEquals(1, list.size());
        assertEquals(42, list.getInt(0));
        try {
            list.getInt(1);
            fail("getInt(1) should throw");
        } catch (IndexOutOfBoundsException e) {
            /* no-op */
        }
        IntListIterator iter = list.iterator();
        assertTrue(iter.hasNext());
        assertFalse(iter.hasPrevious());
        assertEquals(42, iter.nextInt());
        assertFalse(iter.hasNext());
        assertTrue(iter.hasPrevious());
View Full Code Here

        assertEquals(42, iter.previousInt());
    }

    @Test
    public void testBroaderInterval() {
        IntList list = new IntIntervalList(5);
        assertFalse(list.isEmpty());
        assertEquals(5, list.size());
        for (int i = 0; i < 5; i++) {
            assertEquals(i, list.getInt(i));
        }
        try {
            list.getInt(5);
            fail("getInt(5) should throw");
        } catch (IndexOutOfBoundsException e) {
            /* no-op */
        }
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Nullable
    @Override
    public <E extends Event> List<E> getEventsForItem(long item, Class<E> type) {
        IntList index = itemTable.getEntry(item);
        if (index == null) {
            return null;
        }

        if (!type.isAssignableFrom(Rating.class)) {
View Full Code Here

    @SuppressWarnings("unchecked")
    @Nullable
    @Override
    public <E extends Event> UserHistory<E> getEventsForUser(long user, Class<E> type) {
        IntList index = userTable.getEntry(user);
        if (index == null) {
            return null;
        }

        if (!type.isAssignableFrom(Rating.class)) {
View Full Code Here

    public int getRatingCount() {
        return index;
    }

    private void saveIndex(Long2ObjectMap<IntList> map, long key, int index) {
        IntList list = map.get(key);
        if (list == null) {
            list = new IntArrayList();
            map.put(key, list);
        }
        list.add(index);
    }
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.ints.IntList

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.