public static LongList getLCS(LongList aseq, LongList bseq, boolean tryOptimize) { if (aseq == null || bseq == null || aseq.isEmpty() || bseq.isEmpty()) { return LongList.EMPTY; return suffix; boolean hasPrefix = !prefix.isEmpty(); boolean hasSuffix = !suffix.isEmpty(); if (hasPrefix) { aseq = aseq.subList(prefix.size(), aseq.size());
protected void checkValues(long... values) { for (LongList arr : createLongListVariants(values)) { int length = values.length; assertEquals(length == 0, arr.isEmpty()); assertEquals(LongCollections.isSorted(values, 0, length), arr.isSorted()); boolean res = LongCollections.isSortedUnique(false, values, 0, length) == 0; assertEquals(res, arr.isSortedUnique()); checkCollection(arr, values); } }
public void checkMap(T map, LongList keys, IntList values) { assertEquals(keys.size(), map.size()); assertEquals(keys.isEmpty(), map.isEmpty()); for (int i = 0; i < keys.size(); i++) { assertEquals(values.get(i), map.get(keys.get(i))); } LongArray mapKeys = collectIterable(map.size(), map.keysIterator()); CHECK.unordered(mapKeys, keys); IntArray mapValues = IntCollections.collectIterable(map.size(), map.valuesIterator()); CHECK.unordered(mapValues, values); }
public void testRemoveAllSimple() { map.insertAllRo(arithmetic(0, 10), apply(swap(MOD), 3)); LongArray toRemove = LongArray.create(1, 9, 3, 2, 4); LongList notInMap = map.removeAll(toRemove); assertTrue(notInMap.isEmpty()); assertFalse(map.containsAnyKeys(toRemove)); assertEquals(10 - toRemove.size(), map.size()); checkMapValuesEqualKeysMod(3); toRemove = LongArray.create(-2, -1, 0, 1, 5, 6, 8, 10); notInMap = map.removeAll(toRemove); compare.order(notInMap.iterator(), -2, -1, 1, 10); compare.order(map.getKeys().iterator(), 7); checkMapValuesEqualKeysMod(3); map.clear(); map.insertAllRo(arithmetic(0, 10), apply(swap(MOD), 3)); notInMap = map.removeAll(LongArray.create(7, 9, 8)); assertTrue(notInMap.isEmpty()); compare.order(map.getKeys().iterator(), 0, 1, 2, 3, 4, 5, 6); checkMapValuesEqualKeysMod(3); }