assertTrue(map.isEmpty());
}
@Test
public void test3() {
IntToIntMap map = new IntToIntMap();
int length = 100;
for (int i = 0; i < length; ++i) {
map.put(i*64, 100 + i);
}
HashSet<Integer> keySet = new HashSet<Integer>();
for (IntIterator iit = map.keyIterator(); iit.hasNext(); ) {
keySet.add(iit.next());
}
assertEquals(length, keySet.size());
for (int i = 0; i < length; ++i) {
assertTrue(keySet.contains(i * 64));
}
HashSet<Integer> valueSet = new HashSet<Integer>();
for (IntIterator iit = map.iterator(); iit.hasNext(); ) {
valueSet.add(iit.next());
}
assertEquals(length, valueSet.size());
int[] array = map.toArray();
assertEquals(length, array.length);
for (int value: array) {
assertTrue(valueSet.contains(value));
}
int[] array2 = new int[80];
array2 = map.toArray(array2);
assertEquals(length, array2.length);
for (int value: array2) {
assertTrue(valueSet.contains(value));
}
int[] array3 = new int[120];
array3 = map.toArray(array3);
for (int i = 0 ;i < length; ++i) {
assertTrue(valueSet.contains(array3[i]));
}
for (int i = 0; i < length; ++i) {
assertTrue(map.containsValue(i + 100));
assertTrue(map.containsKey(i*64));
}
for (IntIterator iit = map.keyIterator(); iit.hasNext(); ) {
iit.next();
iit.remove();
}
assertTrue(map.isEmpty());
assertEquals(0, map.size());
}