@NotNull @Override public LongIterator iterator() { return myMap.keysIterator(); } }
public void testIteratorConcurrentModificationException2() { // assumed that method createMapsFromLists returns variants with all constructors int attemptsCount = 10; int maxSize = 50; // int maxSize = 1000; for (int attempt = 0; attempt < attemptsCount; attempt++) { LongArray keys = generateRandomLongArray(maxSize, SORTED_UNIQUE); IntArray values = generateRandomIntArray(keys.size(), UNORDERED); for (T map : createMapsFromLists(keys, values)) { int keyForAdd = 0; while (map.containsKey(keyForAdd)) keyForAdd = myRand.nextInt(); LongIterator keysIt = map.keysIterator(); IntIterator valuesIt = map.valuesIterator(); LongIntIterator it = map.iterator(); map.add(keyForAdd, keyForAdd * keyForAdd); checkIteratorThrowsCME(keysIt); checkIteratorThrowsCME(valuesIt); checkIteratorThrowsCME(it); map.remove(keyForAdd); } } }
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 testSimpleMap() { for (int i = 0; i < 10; i++) { map.put(i, i * i); } LongArray expected = new LongArray(range(0, 10)); assertEquals(10, map.size()); assertTrue(map.containsKeys(expected)); LongArray actual = new LongArray(10); for (LongIterator keysIt : map.keysIterator()) { actual.add(keysIt.value()); } actual.sort(); CHECK.order(actual.iterator(), expected.iterator()); for (LongIterator it : expected) { long value = it.value(); assertEquals(value * value, map.get(value)); } }
public void testIterators() { // assumed that method createMapsFromLists returns variants with all constructors int attemptsCount = 10; int maxSize = 50; // int maxSize = 1000; for (int attempt = 0; attempt < attemptsCount; attempt++) { LongArray keys = generateRandomLongArray(maxSize, SORTED_UNIQUE); IntArray values = generateRandomIntArray(keys.size(), UNORDERED); for (T map : createMapsFromLists(keys, values)) { LongArray actualKeys = LongCollections.collectIterables(map.size(), map.keysIterator()); IntArray actualValues = IntCollections.collectIterable(map.size(), map.valuesIterator()); CHECK.unordered(actualKeys, keys); CHECK.unordered(actualValues, values); actualKeys.clear(); actualValues.clear(); for (LongIntIterator iter : map) { actualKeys.add(iter.left()); actualValues.add(iter.right()); } CHECK.unordered(actualKeys, keys); CHECK.unordered(actualValues, values); } } }