本文整理汇总了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() );
}