Package it.unimi.dsi.fastutil.longs

Examples of it.unimi.dsi.fastutil.longs.LongSet


* @author <a href="http://www.grouplens.org">GroupLens Research</a>
*/
public class RemovableLongSortedArraySetTest {
    @Test
    public void testEmptySet() {
        LongSet ls = LongKeyDomain.empty().modifiableActiveSetView();
        assertThat(ls.remove(42), equalTo(false));
    }
View Full Code Here


    }

    @Test
    public void testRemovePresent() {
        LongKeyDomain lks = LongKeyDomain.create(42);
        LongSet ls = lks.modifiableActiveSetView();
        assertThat(ls.remove(42), equalTo(true));
        assertThat(ls.size(), equalTo(0));
        assertThat(lks.size(), equalTo(0));
        assertThat(lks.keyIsActive(42), equalTo(false));
    }
View Full Code Here

    }

    @Test
    public void testRemoveNotPResent() {
        LongKeyDomain lks = LongKeyDomain.create(42);
        LongSet ls = lks.modifiableActiveSetView();
        assertThat(ls.remove(39), equalTo(false));
        assertThat(ls.size(), equalTo(1));
        assertThat(lks.size(), equalTo(1));
        assertThat(lks.keyIsActive(42), equalTo(true));
    }
View Full Code Here

    }

    @Test
    public void testRemoveAll() {
        LongKeyDomain lks = LongKeyDomain.create(20, 25, 30, 42, 62);
        LongSet ls = lks.modifiableActiveSetView();
        List<Long> rm = Longs.asList(20, 25, 62, 30, 98, 1);
        assertThat(ls.removeAll(rm), equalTo(true));
        assertThat(ls, contains(42L));
        assertThat(lks.size(), equalTo(1));
    }
View Full Code Here

    }

    @Test
    public void testRetainAll() {
        LongKeyDomain lks = LongKeyDomain.create(20, 25, 30, 42, 62, 99);
        LongSet ls = lks.modifiableActiveSetView();
        List<Long> rm = Longs.asList(20, 25, 62, 30, 98, 1);
        assertThat(ls.retainAll(rm), equalTo(true));
        assertThat(ls, contains(20L, 25L, 30L, 62L));
        assertThat(Lists.newArrayList(lks.activeIndexIterator(false)),
                   contains(0, 1, 2, 4));
    }
View Full Code Here

    }

    @Test
    public void testRetainAllEmptyList() {
        LongKeyDomain lks = LongKeyDomain.create(20, 25, 30, 42, 62, 99);
        LongSet ls = lks.modifiableActiveSetView();
        assertThat(ls.retainAll(Lists.newArrayList()), equalTo(true));
        assertThat(ls.isEmpty(), equalTo(true));
    }
View Full Code Here

    }

    @Test
    public void testRetainAllLongMaxLong() {
        LongKeyDomain lks = LongKeyDomain.create(20, Long.MAX_VALUE);
        LongSet ls = lks.modifiableActiveSetView();
        assertThat(ls.retainAll(Lists.newArrayList()), equalTo(true));
        assertThat(ls.isEmpty(), equalTo(true));
    }
View Full Code Here

    }

    private class ItemScanner implements Supplier<LongSet> {
        @Override
        public LongSet get() {
            LongSet items = new LongOpenHashSet();
            Cursor<Event> events = eventDAO.streamEvents();
            try {
                for (Event e: events) {
                    items.add(e.getItemId());
                }
            } finally {
                events.close();
            }
            return items;
View Full Code Here

    }

    private class UserScanner implements Supplier<LongSet> {
        @Override
        public LongSet get() {
            LongSet us = new LongOpenHashSet();
            Cursor<Event> events = eventDAO.streamEvents();
            try {
                for (Event e: events) {
                    us.add(e.getUserId());
                }
            } finally {
                events.close();
            }
            return us;
View Full Code Here

    @Override
    public LongSet finishSet() {
        assert size == heap.size();

        LongSet longs = new LongOpenHashSet(size);
        while (!heap.isEmpty()) {
            longs.add(items.get(heap.dequeue()));
        }
        clear();

        return longs;
    }
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.longs.LongSet

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.