for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
map.put( keys[i], vals[i] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.isEmpty() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
assertFalse( set.removeAll( java_set ) );
assertEquals( keys.length, set.size() );
assertEquals( keys.length, map.size() );
for ( int i = 0; i < keys.length; i++ ) {
assertTrue( set.contains( keys[i] ) );
assertTrue( map.containsKey( keys[i] ) );
}
for ( int i = 0; i < keys.length; i++ ) {
java_set.add( Integer.valueOf( keys[i] ) );
}
java_set.remove( 42 );
assertTrue( "set should have been modified: " + set + ", java: " + java_set,
set.removeAll( java_set ) );
assertEquals( "set: " + set, 1, set.size() );
assertEquals( "set: " + set, 1, map.size() );
for ( int i = 0; i < keys.length; i++ ) {
if ( keys[i] == 42 ) {
assertTrue( set.contains( keys[i] ) );
assertTrue( map.containsKey( keys[i] ) );
} else {
assertFalse( set.contains( keys[i] ) );
assertFalse( map.containsKey( keys[i] ) );
}
}
}