@Override public LongIterator get(LongArray... arrays) { return LongCollections.diffSortedUniqueLists(arrays[0], arrays[1]).iterator(); } }, new SetOperationsChecker.DiffGetter(), true, SORTED_UNIQUE);
public void setUp() throws Exception { super.setUp(); it = new LongFindingIterator() { LongIterator innerIt = values.iterator(); @Override protected boolean findNext() { if (!innerIt.hasNext()) return false; myNext = innerIt.nextValue(); return true; } }; }
public void testRemoveAllAtSorted() { LongArray a = new LongArray(LongProgression.arithmetic(0, 20)); LongCollections.removeAllAtSorted(a, IntArray.create(0, 3, 4, 7, 10, 11, 12, 13, 19)); CHECK.order(a.iterator(), 1, 2, 5, 6, 8, 9, 14, 15, 16, 17, 18); LongCollections.removeAllAtSorted(a, IntArray.create(1, 2, 3, 4, 9)); CHECK.order(a.iterator(), 1, 9, 14, 15, 16, 18); }
public void testSimple() { inicIts(); LongIterator res = new LongConcatIterator(its); CHECK.order(LongArray.create(0, 1, 2, 3, 4, 5).iterator(), res); }
public void testRandom() { LongArray[] arrays = new LongArray[5]; for (int i = 0; i < 20; i++) { for (int j = 0; j < arrays.length; j++) { arrays[j] = generateRandomLongArray(30, IntegersFixture.SortedStatus.UNORDERED); } CHECK.order(collectIterables(300, arrays).iterator(), LongIterators.concat(arrays)); } } }
public void checkToBoundedString(String expected, int lim, LongArray array) { WritableLongSet set = LongTreeSet.createFromSortedUnique(array); LongIterable[] iterables = {array, set, array.iterator(), set.iterator(), LongIterators.unionIterator(array, array.subList(0, 1))}; for (LongIterable iterable : iterables) { assertEquals(iterable.toString(), expected, LongCollections.toBoundedString(iterable, lim)); } }
public void setUp() throws Exception { super.setUp(); IntIterator arr1 = IntArray.create(1, 2, 3, 4, 5).iterator(); LongIterator arr2 = LongArray.create(5, 10, 15, 20, 25).iterator(); res = IntLongIterators.pair(arr1, arr2); }
public void testSimpleCase() { LongArray list = LongArray.create(2, 3, 9); IntListIterator indices = IntArray.create(0, 2).iterator(); LongListIndexedIterator res = new LongListIndexedIterator(list, indices); CHECK.order(LongArray.create(2, 9).iterator(), res); }
public void testEmptyCase() { LongArray list = LongArray.create(2, 3, 9); IntIterator indices = IntArray.create().iterator(); LongIndexedIterator res = new LongIndexedIterator(list, indices); CHECK.order(LongArray.create().iterator(), res); }
public void testSimpleCase() { LongArray list = LongArray.create(2, 3, 9); IntIterator indices = IntArray.create(0, 2).iterator(); LongIndexedIterator res = new LongIndexedIterator(list, indices); CHECK.order(LongArray.create(2, 9).iterator(), res); list = LongArray.create(1, 2, 3, 4, 5); indices = IntArray.create(0, 2, 4).iterator(); res = new LongIndexedIterator(list, indices); CHECK.order(LongArray.create(1, 3, 5).iterator(), res); }
public void testIteratorRemove() { LongParallelListMap.Iterator it = myMap.iterator(1); assertFalse(it.hasValue()); it.next(); assertTrue(it.hasValue()); it.removeRange(0, 2); CHECK.order(myMap.keysIterator(0, myMap.size()), LongArray.create(0, 6, 8).iterator()); CHECK.order(myMap.valuesIterator(0, myMap.size()), LongArray.create(1, 31, 41).iterator()); it = myMap.iterator(1); it.next(); it.remove(); CHECK.order(myMap.keysIterator(0, myMap.size()), LongArray.create(0, 8).iterator()); CHECK.order(myMap.valuesIterator(0, myMap.size()), LongArray.create(1, 41).iterator()); }
public void checkToNativeArray(LongArray array) { long[] expected = array.toNativeArray(); LongSet set = LongTreeSet.createFromSortedUnique(array); LongIterable[] iterables = {array, set, array.iterator(), set.iterator(), LongIterators.unionIterator(array, array.isEmpty() ? LongIterator.EMPTY : array.subList(0, 1))}; for (LongIterable iterable: iterables) { CHECK.order(expected, LongCollections.toNativeArray(iterable)); } }
public void testGet() { long[] expected = {0, 1, 2, 5, 6, 7}; CHECK.order(indices.iterator(), decorator.getIndices().iterator()); CHECK.order(source.iterator(), decorator.getSource().iterator()); checkCollection(decorator, expected); }
public void testIterators2() { if (!isSortedSet()) return; for (T set : createSets(range(10))) { LongIterator it1 = set.iterator(); for (int i = 0; i < 5; i++) { assertEquals(i, it1.nextValue()); } // call coalesce CHECK.order(new LongArray(ap(0, 10, 1)), set.toArray()); CHECK.order(new LongArray(ap(0, 10, 1)).iterator(), set.iterator()); CHECK.order(new LongArray(ap(5, 5, 1)).iterator(), it1); } }
public void testRandomCreateFromSorted() { int arrLength = 100; int indicesLength = 50; int maxValue = 1000; LongArray base = generateRandomLongArray(arrLength, UNORDERED, maxValue); for (int test = 0; test < 20; test++) { IntArray indices = generateRandomIntArray(indicesLength, SORTED_UNIQUE, arrLength); LongArray expected = LongArray.copy(base); expected.removeAllAtSorted(indices.iterator()); prepareSortedIndices(indices); LongListRemovingDecorator arr = createFromPrepared(base, indices); CHECK.order(arr.iterator(), expected.iterator()); } }
public static void assertContents(LongIterator it, LongArray values) { int index = 0; while(it.hasNext()) { if(index >= values.size()) { fail("Iterator is too long: " + s(it) + " past expected " + s(values.iterator())); } assertEquals("Wrong value at index " + index, values.get(index), it.nextValue()); index++; } assertEquals("Iterator is too short", values.size(), index); }
public void testInsertAll() { for (WritableLongList list: empty()) { list.addAll(0); list.insertAll(1, LongArray.create(2, 4, 6).iterator()); checkCollection(list, 0, 2, 4, 6); list.insertAll(2, LongArray.create(-5, -10, -15)); checkCollection(list, 0, 2, -5, -10, -15, 4, 6); list.insertAll(0, LongArray.create(0, 99, 99, 0), 1, 2); checkCollection(list, 99, 99, 0, 2, -5, -10, -15, 4, 6); } }
public void testIteratorSetValue() { LongParallelListMap.Iterator it = myMap.iterator(1); assertNotNull(it.iterator()); assertFalse(it.hasValue()); for (; it.hasNext(); it.next()) { it.setRight(1, it.getRight(1) - 11); } assertTrue(it.hasValue()); LongIterator expected = LongArray.create(1, 0, 10, 20, 30).iterator(); CHECK.order(myMap.valuesIterator(0, myMap.size()), expected); }
public void testIndexOfIsEmptyIterator() { LongListConcatenation res = new LongListConcatenation(); assertTrue(res.isEmpty()); LongList[] arrays = {LongArray.create(5, 4, 3), LongArray.create(2, 1), LongArray.create(0)}; for (LongList arr : arrays) { res.addSlice(arr); } assertFalse(res.isEmpty()); for ( int i = 0; i < 6; i++) { assertEquals(5 - i, res.indexOf(i)); } CHECK.order(LongArray.create(5, 4, 3, 2).iterator(), res.iterator(0, 4)); }