@Override protected WritableLongIntMapProjection createSet() { return new WritableLongIntMapProjection(createMap()); }
public void testEquals2() { int attemptsCount = 20; int maxVal = 10; int mapSize = 200; for (int attempt = 0; attempt < attemptsCount; attempt++) { LongArray keys = generateRandomLongArray(mapSize, SORTED_UNIQUE); IntArray values = generateRandomIntArray(keys.size(), UNORDERED, maxVal); for (T map0 : createMapsFromLists(keys, values)) { assertTrue(map0.equals(map0)); assertFalse(map0.equals(null)); assertFalse(map0.equals(LongIntMap.EMPTY)); assertTrue(map0.equals(map0)); T expected = createMap(); expected.putAllKeys(keys.subList(0, keys.size() - 1), values); expected.put(keys.getLast(0), values.getLast(0) != 0 ? 0 : 1); assertFalse(map0.equals(expected)); for (T map1 : createMapsFromLists(keys, values)) { assertEquals(map1, map0); } } } } }
@Override public void testHashCode() { int attemptsCount = 10, shuffleCount = 10; int sizeMax = 600, step = 50; for (int attempt = 0; attempt < attemptsCount; attempt++) { for (int mSize = step; mSize < sizeMax; mSize += step) { LongArray keys = generateRandomLongArray(mSize, SORTED_UNIQUE); int size = keys.size(); IntArray values = generateRandomIntArray(size, UNORDERED); int expectedHash = 0; for (int i = 0; i < size; i++) { expectedHash += IntegersUtils.hash(keys.get(i)) + IntegersUtils.hash(values.get(i)); } for (T map0 : createMapsFromLists(keys, values)) { assertEquals(expectedHash, map0.hashCode()); } IntArray indices = new IntArray(IntProgression.range(size)); for (int i = 0; i < shuffleCount; i++) { map = createMap(); map.putAll(keys.get(indices), values.get(indices)); assertEquals(expectedHash, map.hashCode()); indices.shuffle(myRand); } } } }
public void setUp() throws Exception { super.setUp(); map = createMap(); }
@Override protected WritableLongIntMapProjection createSet(LongList sortedUniqueList) { T map0 = createMap(); map0.putAll(sortedUniqueList, repeat(DEFAULT_CONTAINS_VALUE, sortedUniqueList.size())); return new WritableLongIntMapProjection(map0); }