vals[i] = Integer.toString( i + 1 );
map.put( keys[i], vals[i] );
}
assertEquals( element_count, map.size() );
TIntSet keyset = map.keySet();
for ( int i = 0; i < keyset.size(); i++ ) {
assertTrue( keyset.contains( keys[i] ) );
}
assertFalse( keyset.isEmpty() );
int[] keys_array = keyset.toArray();
int count = 0;
TIntIterator iter = keyset.iterator();
while ( iter.hasNext() ) {
int key = iter.next();
assertTrue( keyset.contains( key ) );
assertEquals( keys_array[count], key );
count++;
}
//noinspection ToArrayCallWithZeroLengthArrayArgument
keys_array = keyset.toArray( new int[0] );
count = 0;
iter = keyset.iterator();
while ( iter.hasNext() ) {
int key = iter.next();
assertTrue( keyset.contains( key ) );
assertEquals( keys_array[count], key );
count++;
}
keys_array = keyset.toArray( new int[keyset.size()] );
count = 0;
iter = keyset.iterator();
while ( iter.hasNext() ) {
int key = iter.next();
assertTrue( keyset.contains( key ) );
assertEquals( keys_array[count], key );
count++;
}
keys_array = keyset.toArray( new int[keyset.size() * 2] );
count = 0;
iter = keyset.iterator();
while ( iter.hasNext() ) {
int key = iter.next();
assertTrue( keyset.contains( key ) );
assertEquals( keys_array[count], key );
count++;
}
assertEquals( keyset.getNoEntryValue(), keys_array[keyset.size()] );
TIntSet other = new TIntHashSet( keyset );
assertFalse( keyset.retainAll( other ) );
other.remove( keys[5] );
assertTrue( keyset.retainAll( other ) );
assertFalse( keyset.contains( keys[5] ) );
assertFalse( map.containsKey( keys[5] ) );
keyset.clear();