for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
map.put( keys[i], vals[i] );
}
TLongCollection values = map.valueCollection();
assertEquals( map.size(), values.size() );
assertFalse( values.isEmpty() );
assertTrue( values.removeAll( values ) );
assertTrue( values.isEmpty() );
// repopulate the set.
map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
map.put( keys[i], vals[i] );
}
values = map.valueCollection();
// With empty set
TLongSet tlongset = new TLongHashSet();
assertFalse( "values: " + values + ", collection: " + tlongset,
values.removeAll( tlongset ) );
// With partial set
tlongset = new TLongHashSet( vals );
tlongset.remove( 42 * 2 );
assertTrue( "values: " + values + ", collection: " + tlongset,
values.removeAll( tlongset ) );
assertEquals( "set: " + values, 1, values.size() );
assertEquals( "set: " + values, 1, map.size() );
for ( int i = 0; i < keys.length; i++ ) {
if ( keys[i] == 42 ) {
assertTrue( values.contains( vals[i] ) );
assertTrue( map.containsValue( vals[i] ) );
} else {
assertFalse( values.contains( vals[i] ) );
assertFalse( map.containsValue( vals[i] ) );
}
}
// repopulate the set.
map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
map.put( keys[i], vals[i] );
}
values = map.valueCollection();
// Empty list
TLongCollection collection = new TLongArrayList();
assertFalse( "values: " + values + ", collection: " + collection,
values.removeAll( collection ) );
// partial list
collection = new TLongArrayList( vals );
collection.remove( 42 * 2 );
assertTrue( "values: " + values + ", collection: " + collection,
values.removeAll( collection ) );
assertEquals( "values: " + values, 1, values.size() );
assertEquals( "values: " + values, 1, map.size() );
for ( int i = 0; i < keys.length; i++ ) {