本文整理匯總了Java中gnu.trove.map.TIntObjectMap.valueCollection方法的典型用法代碼示例。如果您正苦於以下問題:Java TIntObjectMap.valueCollection方法的具體用法?Java TIntObjectMap.valueCollection怎麽用?Java TIntObjectMap.valueCollection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gnu.trove.map.TIntObjectMap
的用法示例。
在下文中一共展示了TIntObjectMap.valueCollection方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testValueCollectionRetainAllCollection
import gnu.trove.map.TIntObjectMap; //導入方法依賴的package包/類
public void testValueCollectionRetainAllCollection() {
int element_count = 20;
int[] keys = new int[element_count];
String[] vals = new String[element_count];
TIntObjectMap<String> map = new TIntObjectHashMap<String>();
for ( int i = 0; i < element_count; i++ ) {
keys[i] = i + 1;
vals[i] = Integer.toString( i + 1 );
map.put( keys[i], vals[i] );
}
assertEquals( element_count, map.size() );
Collection<String> collection = map.valueCollection();
for ( int i = 0; i < collection.size(); i++ ) {
assertTrue( collection.contains( vals[i] ) );
}
assertFalse( collection.isEmpty() );
List<String> java_list = new ArrayList<String>();
java_list.addAll( Arrays.asList( vals ) );
assertFalse( "collection: " + collection + ", should contain all in list: " +
java_list, collection.retainAll( java_list ) );
java_list.remove( 5 );
assertTrue( "collection: " + collection + ", should contain all in list: " +
java_list, collection.retainAll( java_list ) );
assertFalse( collection.contains( vals[5] ) );
assertFalse( map.containsKey( keys[5] ) );
assertFalse( map.containsValue( vals[5] ) );
assertTrue( "collection: " + collection + ", should contain all in list: " +
java_list, collection.containsAll( java_list ) );
}
示例2: testValueCollectionRetainAllTCollection
import gnu.trove.map.TIntObjectMap; //導入方法依賴的package包/類
public void testValueCollectionRetainAllTCollection() {
int element_count = 20;
int[] keys = new int[element_count];
String[] vals = new String[element_count];
TIntObjectMap<String> map = new TIntObjectHashMap<String>();
for ( int i = 0; i < element_count; i++ ) {
keys[i] = i + 1;
vals[i] = Integer.toString( i + 1 );
map.put( keys[i], vals[i] );
}
assertEquals( element_count, map.size() );
Collection<String> collection = map.valueCollection();
for ( int i = 0; i < collection.size(); i++ ) {
assertTrue( collection.contains( vals[i] ) );
}
assertFalse( collection.isEmpty() );
assertFalse( "collection: " + collection + ", should be unmodified.",
collection.retainAll( collection ) );
Collection<String> other = new ArrayList<String>( collection );
assertFalse( "collection: " + collection + ", should be unmodified. other: " +
other, collection.retainAll( other ) );
other.remove( vals[5] );
assertTrue( "collection: " + collection + ", should be modified. other: " +
other, collection.retainAll( other ) );
assertFalse( collection.contains( vals[5] ) );
assertFalse( map.containsKey( keys[5] ) );
assertFalse( map.containsValue( vals[5] ) );
assertTrue( "collection: " + collection + ", should contain all in other: " +
other, collection.containsAll( other ) );
}
示例3: testValueCollectionRemoveAllCollection
import gnu.trove.map.TIntObjectMap; //導入方法依賴的package包/類
public void testValueCollectionRemoveAllCollection() {
int element_count = 20;
int[] keys = new int[element_count];
String[] vals = new String[element_count];
TIntObjectMap<String> map = new TIntObjectHashMap<String>();
for ( int i = 0; i < element_count; i++ ) {
keys[i] = i + 1;
vals[i] = Integer.toString( i + 1 );
map.put( keys[i], vals[i] );
}
assertEquals( element_count, map.size() );
Collection<String> collection = map.valueCollection();
for ( int i = 0; i < collection.size(); i++ ) {
assertTrue( collection.contains( vals[i] ) );
}
assertFalse( collection.isEmpty() );
List<String> java_list = new ArrayList<String>();
assertFalse( "collection: " + collection + ", should contain all in list: " +
java_list, collection.removeAll( java_list ) );
java_list.add( vals[5] );
assertTrue( "collection: " + collection + ", should contain all in list: " +
java_list, collection.removeAll( java_list ) );
assertFalse( collection.contains( vals[5] ) );
assertFalse( map.containsKey( keys[5] ) );
assertFalse( map.containsValue( vals[5] ) );
java_list = new ArrayList<String>();
java_list.addAll( Arrays.asList( vals ) );
assertTrue( "collection: " + collection + ", should contain all in list: " +
java_list, collection.removeAll( java_list ) );
assertTrue( collection.isEmpty() );
}
示例4: testValueCollectionContainsAll
import gnu.trove.map.TIntObjectMap; //導入方法依賴的package包/類
public void testValueCollectionContainsAll() {
int element_count = 20;
int[] keys = new int[element_count];
String[] vals = new String[element_count];
TIntObjectMap<String> map = new TIntObjectHashMap<String>();
for ( int i = 0; i < element_count; i++ ) {
keys[i] = i + 1;
vals[i] = Integer.toString( i + 1 );
map.put( keys[i], vals[i] );
}
assertEquals( element_count, map.size() );
Collection<String> collection = map.valueCollection();
for ( int i = 0; i < collection.size(); i++ ) {
assertTrue( collection.contains( vals[i] ) );
}
assertFalse( collection.isEmpty() );
List<String> java_list = new ArrayList<String>();
java_list.addAll( Arrays.asList( vals ) );
assertTrue( "collection: " + collection + ", should contain all in list: " +
java_list, collection.containsAll( java_list ) );
java_list.add( String.valueOf( 1138 ) );
assertFalse( "collection: " + collection + ", should not contain all in list: " +
java_list, collection.containsAll( java_list ) );
List<CharSequence> number_list = new ArrayList<CharSequence>();
for ( String value : vals ) {
if ( value.equals( "5" ) ) {
number_list.add( new StringBuilder().append( value ) );
} else {
number_list.add( String.valueOf( value ) );
}
}
assertFalse( "collection: " + collection + ", should not contain all in list: " +
java_list, collection.containsAll( number_list ) );
Collection<String> other = new ArrayList<String>( collection );
assertTrue( "collection: " + collection + ", should contain all in other: " +
other, collection.containsAll( other ) );
other.add( "1138" );
assertFalse( "collection: " + collection + ", should not contain all in other: " +
other, collection.containsAll( other ) );
}
示例5: testValueCollectionRemoveAllTCollection
import gnu.trove.map.TIntObjectMap; //導入方法依賴的package包/類
public void testValueCollectionRemoveAllTCollection() {
int element_count = 20;
int[] keys = new int[element_count];
String[] vals = new String[element_count];
TIntObjectMap<String> map = new TIntObjectHashMap<String>();
for ( int i = 0; i < element_count; i++ ) {
keys[i] = i + 1;
vals[i] = Integer.toString( i + 1 );
map.put( keys[i], vals[i] );
}
assertEquals( element_count, map.size() );
Collection<String> collection = map.valueCollection();
for ( int i = 0; i < collection.size(); i++ ) {
assertTrue( collection.contains( vals[i] ) );
}
assertFalse( collection.isEmpty() );
Collection<String> other = new ArrayList<String>();
assertFalse( "collection: " + collection + ", should be unmodified.",
collection.removeAll( other ) );
other = new ArrayList<String>( collection );
other.remove( vals[5] );
assertTrue( "collection: " + collection + ", should be modified. other: " +
other, collection.removeAll( other ) );
assertEquals( 1, collection.size() );
for ( int i = 0; i < element_count; i++ ) {
if ( i == 5 ) {
assertTrue( collection.contains( vals[i] ) );
assertTrue( map.containsKey( keys[i] ) );
assertTrue( map.containsValue( vals[i] ) );
} else {
assertFalse( collection.contains( vals[i] ) );
assertFalse( map.containsKey( keys[i] ) );
assertFalse( map.containsValue( vals[i] ) );
}
}
assertFalse( "collection: " + collection + ", should be unmodified. other: " +
other, collection.removeAll( other ) );
assertTrue( "collection: " + collection + ", should be modified. other: " +
other, collection.removeAll( collection ) );
assertTrue( collection.isEmpty() );
}