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