本文整理汇总了Java中gnu.trove.map.TIntLongMap.valueCollection方法的典型用法代码示例。如果您正苦于以下问题:Java TIntLongMap.valueCollection方法的具体用法?Java TIntLongMap.valueCollection怎么用?Java TIntLongMap.valueCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.TIntLongMap
的用法示例。
在下文中一共展示了TIntLongMap.valueCollection方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testValueCollectionHashCode
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testValueCollectionHashCode() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongHashMap();
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() );
assertEquals( "hashcodes incorrectly not equal: " + map + ", " + values,
values.hashCode(), values.hashCode() );
assertFalse( "hashcodes incorrectly equal: " + map + ", " + values,
map.hashCode() == values.hashCode() );
}
示例2: testValueCollectionHashCode
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testValueCollectionHashCode() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongOffheapHashMap();
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() );
assertEquals( "hashcodes incorrectly not equal: " + map + ", " + values,
values.hashCode(), values.hashCode() );
assertFalse( "hashcodes incorrectly equal: " + map + ", " + values,
map.hashCode() == values.hashCode() );
}
示例3: testValueCollectionContainsAll
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testValueCollectionContainsAll() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongHashMap();
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() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
for ( int i = 0; i < vals.length; i++ ) {
java_set.add( Long.valueOf( vals[i] ) );
}
assertTrue( values.containsAll( java_set ) );
java_set.add( Integer.valueOf( 12 ) );
assertFalse( values.containsAll( java_set ) );
java_set.remove( Integer.valueOf( 12 ) );
assertTrue( values.containsAll( java_set ) );
java_set.add( Long.valueOf( 12 ) );
assertFalse( values.containsAll( java_set ) );
// test with a TCollection
TLongSet tintset = new TLongHashSet( vals );
assertTrue( values.containsAll( tintset ) );
tintset.add( 12 );
assertFalse( values.containsAll( tintset ) );
// test raw array
assertTrue( values.containsAll( vals ) );
vals[3] = vals[3] + 1;
assertFalse( values.containsAll( vals ) );
}
示例4: testValueCollectionRetainAllTCollection
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testValueCollectionRetainAllTCollection() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongHashMap();
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() );
assertFalse( values.retainAll( values ) );
// test with a TCollection
TLongSet tintset = new TLongHashSet( vals );
assertFalse( "values: " + values + ", collection: " + tintset,
values.retainAll( tintset ) );
TLongCollection collection = new TLongArrayList( vals );
assertFalse( "values: " + values + ", collection: " + collection,
values.retainAll( collection ) );
collection.remove( 42 * 2 );
assertTrue( "values: " + values + ", collection: " + collection,
values.retainAll( collection ) );
assertEquals( keys.length - 1, values.size() );
assertEquals( keys.length - 1, map.size() );
}
示例5: testValueCollectionRetainAllArray
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testValueCollectionRetainAllArray() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongHashMap();
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() );
// test raw array
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();
assertFalse( values.retainAll( vals ) );
assertTrue( values.containsAll( vals ) );
vals[3] = vals[3] + 1;
assertTrue( values.retainAll( vals ) );
vals[3] = vals[3] - 1;
assertEquals( "removed: " + keys[3] + ", values: " + values,
keys.length - 1, values.size() );
assertEquals( "removed: " + keys[3] + ", set: " + values
+ "\nmap: " + map, values.size(), map.size() );
}
示例6: testValueCollectionRemoveAllArray
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testValueCollectionRemoveAllArray() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongHashMap();
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() );
// test raw array
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();
vals[3] = vals[3] + 1;
assertTrue( values.removeAll( vals ) );
vals[3] = vals[3] - 1;
assertEquals( "removed: " + keys[3] + ", values: " + values,
1, values.size() );
assertEquals( "removed: " + keys[3] + ", values: " + values
+ "\nmap: " + map, values.size(), map.size() );
}
示例7: testValueCollectionContainsAll
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testValueCollectionContainsAll() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongOffheapHashMap();
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() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
for ( int i = 0; i < vals.length; i++ ) {
java_set.add( Long.valueOf( vals[i] ) );
}
assertTrue( values.containsAll( java_set ) );
java_set.add( Integer.valueOf( 12 ) );
assertFalse( values.containsAll( java_set ) );
java_set.remove( Integer.valueOf( 12 ) );
assertTrue( values.containsAll( java_set ) );
java_set.add( Long.valueOf( 12 ) );
assertFalse( values.containsAll( java_set ) );
// test with a TCollection
TLongSet tintset = new TLongHashSet( vals );
assertTrue( values.containsAll( tintset ) );
tintset.add( 12 );
assertFalse( values.containsAll( tintset ) );
// test raw array
assertTrue( values.containsAll( vals ) );
vals[3] = vals[3] + 1;
assertFalse( values.containsAll( vals ) );
}
示例8: testValueCollectionRetainAllTCollection
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testValueCollectionRetainAllTCollection() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongOffheapHashMap();
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() );
assertFalse( values.retainAll( values ) );
// test with a TCollection
TLongSet tintset = new TLongHashSet( vals );
assertFalse( "values: " + values + ", collection: " + tintset,
values.retainAll( tintset ) );
TLongCollection collection = new TLongArrayList( vals );
assertFalse( "values: " + values + ", collection: " + collection,
values.retainAll( collection ) );
collection.remove( 42 * 2 );
assertTrue( "values: " + values + ", collection: " + collection,
values.retainAll( collection ) );
assertEquals( keys.length - 1, values.size() );
assertEquals( keys.length - 1, map.size() );
}
示例9: testValueCollectionRemoveAllArray
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testValueCollectionRemoveAllArray() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongOffheapHashMap();
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() );
// test raw array
map = new TIntLongOffheapHashMap();
for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
map.put( keys[i], vals[i] );
}
values = map.valueCollection();
vals[3] = vals[3] + 1;
assertTrue( values.removeAll( vals ) );
vals[3] = vals[3] - 1;
assertEquals( "removed: " + keys[3] + ", values: " + values,
1, values.size() );
assertEquals( "removed: " + keys[3] + ", values: " + values
+ "\nmap: " + map, values.size(), map.size() );
}
示例10: testValueCollectionMisc
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testValueCollectionMisc() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
map.put( keys[i], vals[i] );
}
TLongCollection values = map.valueCollection();
long[] sorted_keys = new long[ vals.length ];
System.arraycopy( vals, 0, sorted_keys, 0, vals.length );
Arrays.sort( sorted_keys );
long[] setarray = values.toArray();
Arrays.sort( setarray );
assertTrue( "expected: " + Arrays.toString( sorted_keys ) +
", was: " + Arrays.toString( setarray ),
Arrays.equals( sorted_keys, setarray ) );
setarray = values.toArray( new long[0] );
Arrays.sort( setarray );
assertTrue( "expected: " + Arrays.toString( sorted_keys ) +
", was: " + Arrays.toString( setarray ),
Arrays.equals( sorted_keys, setarray ) );
assertFalse( "remove of element not in collection succeded: " + values,
values.remove( 1 ) );
assertEquals( keys.length, values.size() );
assertEquals( keys.length, map.size() );
assertTrue( "remove of element in collection failed: " + values,
values.remove( 42 * 2 ) );
assertEquals( keys.length - 1, values.size() );
assertEquals( keys.length - 1, map.size() );
try {
values.add( 42 );
fail( "Expected UnsupportedOperationException" );
}
catch ( UnsupportedOperationException ex ) {
// Expected
}
}
示例11: testValueCollectionRemoveAllCollection
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testValueCollectionRemoveAllCollection() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongHashMap();
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() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
assertFalse( values.removeAll( java_set ) );
assertEquals( vals.length, values.size() );
assertEquals( vals.length, map.size() );
for ( int i = 0; i < keys.length; i++ ) {
assertTrue( values.contains( vals[i] ) );
assertTrue( map.containsValue( vals[i] ) );
}
for ( int i = 0; i < vals.length; i++ ) {
java_set.add( Long.valueOf( vals[i] ) );
}
java_set.remove( Long.valueOf( 42 * 2 ) );
assertTrue( "values should have been modified: " + values + ", java: " + java_set,
values.removeAll( java_set ) );
assertEquals( "set: " + values, 1, values.size() );
assertEquals( "set: " + values, 1, map.size() );
for ( int i = 0; i < vals.length; i++ ) {
if ( vals[i] == 42 * 2 ) {
assertTrue( values.contains( vals[i] ) );
assertTrue( map.containsValue( vals[i] ) );
} else {
assertFalse( values.contains( vals[i] ) );
assertFalse( map.containsValue( vals[i] ) );
}
}
}
示例12: testValueCollectionMisc
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testValueCollectionMisc() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongOffheapHashMap();
for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
map.put( keys[i], vals[i] );
}
TLongCollection values = map.valueCollection();
long[] sorted_keys = new long[ vals.length ];
System.arraycopy( vals, 0, sorted_keys, 0, vals.length );
Arrays.sort( sorted_keys );
long[] setarray = values.toArray();
Arrays.sort( setarray );
assertTrue( "expected: " + Arrays.toString( sorted_keys ) +
", was: " + Arrays.toString( setarray ),
Arrays.equals( sorted_keys, setarray ) );
setarray = values.toArray( new long[0] );
Arrays.sort( setarray );
assertTrue( "expected: " + Arrays.toString( sorted_keys ) +
", was: " + Arrays.toString( setarray ),
Arrays.equals( sorted_keys, setarray ) );
assertFalse( "remove of element not in collection succeded: " + values,
values.remove( 1 ) );
assertEquals( keys.length, values.size() );
assertEquals( keys.length, map.size() );
assertTrue( "remove of element in collection failed: " + values,
values.remove( 42 * 2 ) );
assertEquals( keys.length - 1, values.size() );
assertEquals( keys.length - 1, map.size() );
try {
values.add( 42 );
fail( "Expected UnsupportedOperationException" );
}
catch ( UnsupportedOperationException ex ) {
// Expected
}
}
示例13: testValueCollectionRetainAllCollection
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testValueCollectionRetainAllCollection() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongOffheapHashMap();
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() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
for ( int i = 0; i < vals.length; i++ ) {
java_set.add( Long.valueOf( vals[i] ) );
}
assertFalse( values.retainAll( java_set ) );
assertEquals( keys.length, values.size() );
assertEquals( keys.length, map.size() );
for ( int i = 0; i < keys.length; i++ ) {
assertTrue( values.contains( vals[i] ) );
assertTrue( map.containsValue( vals[i] ) );
}
java_set.remove( Long.valueOf( 42 * 2 ) );
assertTrue( "collection should have been modified: " + values +
"\njava: " + java_set,
values.retainAll( java_set ) );
assertEquals( keys.length - 1, values.size() );
assertEquals( keys.length - 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] ) );
}
}
}
示例14: testValueCollectionRemoveAllCollection
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testValueCollectionRemoveAllCollection() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongOffheapHashMap();
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() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
assertFalse( values.removeAll( java_set ) );
assertEquals( vals.length, values.size() );
assertEquals( vals.length, map.size() );
for ( int i = 0; i < keys.length; i++ ) {
assertTrue( values.contains( vals[i] ) );
assertTrue( map.containsValue( vals[i] ) );
}
for ( int i = 0; i < vals.length; i++ ) {
java_set.add( Long.valueOf( vals[i] ) );
}
java_set.remove( Long.valueOf( 42 * 2 ) );
assertTrue( "values should have been modified: " + values + ", java: " + java_set,
values.removeAll( java_set ) );
assertEquals( "set: " + values, 1, values.size() );
assertEquals( "set: " + values, 1, map.size() );
for ( int i = 0; i < vals.length; i++ ) {
if ( vals[i] == 42 * 2 ) {
assertTrue( values.contains( vals[i] ) );
assertTrue( map.containsValue( vals[i] ) );
} else {
assertFalse( values.contains( vals[i] ) );
assertFalse( map.containsValue( vals[i] ) );
}
}
}