public void testGetSimple() { IntArray prepared = IntArray.create(2); prepareSortedIndices(prepared); LongListRemovingDecorator rem = createFromPrepared(range(0, 4), prepared); LongListIterator it = rem.iterator(); it.next(); assertEquals(3, it.get(2)); it.next(); assertEquals(3, it.get(1)); }
public void testIteratorGet() { LongArray source = LongArray.create(10, 13, 15, 14, 11, 12, 16, 17, 18), expected = LongArray.create(10, 15, 14, 12, 16, 18); IntArray indices = IntArray.create(1, 4, 7); prepareSortedIndices(indices); LongListRemovingDecorator tst2 = createFromPrepared(source, indices); LongListIterator it = tst2.iterator(), expIt = expected.iterator(); while (it.hasNext()) { assertEquals(it.nextValue(), expIt.nextValue()); } assertEquals(it.hasNext(), expIt.hasNext()); for (int i = 0; i < expected.size(); i++) { assertEquals(it.get(-i), expIt.get(-i)); } }
public void testSimple() { LongArray array = LongArray.create(0, 1, 2, 3, 4, 5, 6); IntArray indices = IntArray.create(1, 3, 5); prepareSortedIndices(indices); LongListRemovingDecorator rem = createFromPrepared(array, indices); LongArray expected = LongArray.create(0, 2, 4, 6); CHECK.order(expected, rem); LongListIterator it = rem.iterator(); for (int i = 0; i < expected.size(); i++) { assertEquals(expected.get(i), rem.get(i)); assertEquals(expected.get(i), it.nextValue()); } }
public void testIterator() { LongArray source = LongArray.create(10,13,15,14,11,12,16,17,18), expected = LongArray.create(10,15,14,12,16,18), result = new LongArray(); IntArray indices = IntArray.create(1, 4, 7); prepareSortedIndices(indices); LongListRemovingDecorator tst2 = createFromPrepared(source, indices); result.addAll(tst2.iterator()); assertEquals(expected, result); }
public void testCompound() { long[][] valuesArray = {{0, 1, 2, 3, 4, 5, 6}, {10, 11, 12, 13, 14, 15, 16}}; int[][] indicesToRemove = {{0, 4, 1, 5}, {2, 6, 1}, {0, 6, 1, 2}}; for (long[] values : valuesArray) { LongArray array = LongArray.create(values); for (int[] indices : indicesToRemove) { IntList removedIndices = LongListRemovingDecorator.prepareUnsortedIndices(indices); LongListRemovingDecorator rem = createFromPrepared(array, removedIndices); LongArray expected = LongArray.copy(values); removedIndices = IntCollections.toSorted(false, new IntArray(indices)); expected.removeAllAtSorted(removedIndices.iterator()); CHECK.order(expected, rem); checkRemovedIndexes(rem, removedIndices.toNativeArray()); assertEquals(indices.length, rem.getRemoveCount()); } } }