本文整理汇总了Java中gnu.trove.map.TIntLongMap.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java TIntLongMap.keySet方法的具体用法?Java TIntLongMap.keySet怎么用?Java TIntLongMap.keySet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.TIntLongMap
的用法示例。
在下文中一共展示了TIntLongMap.keySet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testKeySetRemoveAllArray
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRemoveAllArray() {
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] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.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] );
}
set = map.keySet();
keys[3] = keys[3] + 1;
assertTrue( set.removeAll( keys ) );
keys[3] = keys[3] - 1;
assertEquals( "removed: " + keys[3] + ", set: " + set,
1, set.size() );
assertEquals( "removed: " + keys[3] + ", set: " + set
+ "\nmap: " + map, set.size(), map.size() );
}
示例2: testKeySetRetainAllArray
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRetainAllArray() {
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] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.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] );
}
set = map.keySet();
assertFalse( set.retainAll( keys ) );
assertTrue( set.containsAll( keys ) );
keys[3] = keys[3] + 1;
assertTrue( set.retainAll( keys ) );
keys[3] = keys[3] - 1;
assertEquals( "removed: " + keys[3] + ", set: " + set,
keys.length - 1, set.size() );
assertEquals( "removed: " + keys[3] + ", set: " + set
+ "\nmap: " + map, set.size(), map.size() );
}
示例3: testKeySetEquals
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetEquals() {
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] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.isEmpty() );
TIntSet other = new TIntHashSet();
other.addAll( keys );
assertTrue( "sets incorrectly not equal: " + set + ", " + other,
set.equals( other ) );
int[] mismatched = {72, 49, 53, 1024, 999};
TIntSet unequal = new TIntHashSet();
unequal.addAll( mismatched );
assertFalse( "sets incorrectly equal: " + set + ", " + unequal,
set.equals( unequal ) );
// Change length, different code branch
unequal.add( 1 );
assertFalse( "sets incorrectly equal: " + set + ", " + unequal,
set.equals( unequal ) );
assertFalse( "set incorrectly equals a random object",
set.equals( new Object() ) );
}
示例4: testKeySetRetainAllTCollection
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRetainAllTCollection() {
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] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.isEmpty() );
assertFalse( set.retainAll( set ) );
// test with a TCollection
TIntSet tintset = new TIntHashSet( keys );
assertFalse( "set: " + set + ", collection: " + tintset,
set.retainAll( tintset ) );
TIntCollection collection = new TIntArrayList( keys );
assertFalse( "set: " + set + ", collection: " + collection,
set.retainAll( collection ) );
collection.remove( 42 );
assertTrue( "set: " + set + ", collection: " + collection,
set.retainAll( collection ) );
assertEquals( keys.length - 1, set.size() );
assertEquals( keys.length - 1, map.size() );
}
示例5: testKeySetContainsAll
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetContainsAll() {
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] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.isEmpty() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
for ( int i = 0; i < keys.length; i++ ) {
java_set.add( Integer.valueOf( keys[i] ) );
}
assertTrue( set.containsAll( java_set ) );
java_set.add( Integer.valueOf( 12 ) );
assertFalse( set.containsAll( java_set ) );
java_set.remove( Integer.valueOf( 12 ) );
assertTrue( set.containsAll( java_set ) );
java_set.add( Long.valueOf( 12 ) );
assertFalse( set.containsAll( java_set ) );
// test with a TCollection
TIntSet tintset = new TIntHashSet( keys );
assertTrue( set.containsAll( tintset ) );
tintset.add( 12 );
assertFalse( set.containsAll( tintset ) );
// test raw array
assertTrue( set.containsAll( keys ) );
keys[3] = keys[3] + 1;
assertFalse( set.containsAll( keys ) );
}
示例6: testKeySetRetainAllTCollection
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRetainAllTCollection() {
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] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.isEmpty() );
assertFalse( set.retainAll( set ) );
// test with a TCollection
TIntSet tintset = new TIntHashSet( keys );
assertFalse( "set: " + set + ", collection: " + tintset,
set.retainAll( tintset ) );
TIntCollection collection = new TIntArrayList( keys );
assertFalse( "set: " + set + ", collection: " + collection,
set.retainAll( collection ) );
collection.remove( 42 );
assertTrue( "set: " + set + ", collection: " + collection,
set.retainAll( collection ) );
assertEquals( keys.length - 1, set.size() );
assertEquals( keys.length - 1, map.size() );
}
示例7: testKeySetRetainAllArray
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRetainAllArray() {
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] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.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] );
}
set = map.keySet();
assertFalse( set.retainAll( keys ) );
assertTrue( set.containsAll( keys ) );
keys[3] = keys[3] + 1;
assertTrue( set.retainAll( keys ) );
keys[3] = keys[3] - 1;
assertEquals( "removed: " + keys[3] + ", set: " + set,
keys.length - 1, set.size() );
assertEquals( "removed: " + keys[3] + ", set: " + set
+ "\nmap: " + map, set.size(), map.size() );
}
示例8: testKeySetRetainAllArray
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRetainAllArray() {
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] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.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] );
}
set = map.keySet();
assertFalse( set.retainAll( keys ) );
assertTrue( set.containsAll( keys ) );
keys[3] = keys[3] + 1;
assertTrue( set.retainAll( keys ) );
keys[3] = keys[3] - 1;
assertEquals( "removed: " + keys[3] + ", set: " + set,
keys.length - 1, set.size() );
assertEquals( "removed: " + keys[3] + ", set: " + set
+ "\nmap: " + map, set.size(), map.size() );
}
示例9: testKeySetEquals
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetEquals() {
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] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.isEmpty() );
TIntSet other = new TIntHashSet();
other.addAll( keys );
assertTrue( "sets incorrectly not equal: " + set + ", " + other,
set.equals( other ) );
int[] mismatched = {72, 49, 53, 1024, 999};
TIntSet unequal = new TIntHashSet();
unequal.addAll( mismatched );
assertFalse( "sets incorrectly equal: " + set + ", " + unequal,
set.equals( unequal ) );
// Change length, different code branch
unequal.add( 1 );
assertFalse( "sets incorrectly equal: " + set + ", " + unequal,
set.equals( unequal ) );
assertFalse( "set incorrectly equals a random object",
set.equals( new Object() ) );
}
示例10: testKeySetHashCode
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetHashCode() {
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] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.isEmpty() );
TIntSet other = new TIntHashSet();
other.addAll( keys );
assertTrue( "hashcodes incorrectly not equal: " + set + ", " + other,
set.hashCode() == other.hashCode() );
int[] mismatched = {72, 49, 53, 1024, 999};
TIntSet unequal = new TIntHashSet();
unequal.addAll( mismatched );
assertFalse( "hashcodes unlikely equal: " + set + ", " + unequal,
set.hashCode() == unequal.hashCode() );
}
示例11: testKeySetContainsAll
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetContainsAll() {
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] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.isEmpty() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
for ( int i = 0; i < keys.length; i++ ) {
java_set.add( Integer.valueOf( keys[i] ) );
}
assertTrue( set.containsAll( java_set ) );
java_set.add( Integer.valueOf( 12 ) );
assertFalse( set.containsAll( java_set ) );
java_set.remove( Integer.valueOf( 12 ) );
assertTrue( set.containsAll( java_set ) );
java_set.add( Long.valueOf( 12 ) );
assertFalse( set.containsAll( java_set ) );
// test with a TCollection
TIntSet tintset = new TIntHashSet( keys );
assertTrue( set.containsAll( tintset ) );
tintset.add( 12 );
assertFalse( set.containsAll( tintset ) );
// test raw array
assertTrue( set.containsAll( keys ) );
keys[3] = keys[3] + 1;
assertFalse( set.containsAll( keys ) );
}
示例12: testKeySetMisc
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetMisc() {
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] );
}
TIntSet set = map.keySet();
int[] sorted_keys = new int[ keys.length ];
System.arraycopy( keys, 0, sorted_keys, 0, keys.length );
Arrays.sort( sorted_keys );
int[] setarray = set.toArray();
Arrays.sort( setarray );
assertTrue( "expected: " + Arrays.toString( sorted_keys ) +
", was: " + Arrays.toString( setarray ),
Arrays.equals( sorted_keys, setarray ) );
setarray = set.toArray( new int[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 set succeded: " + set, set.remove( 1 ) );
assertEquals( keys.length, set.size() );
assertEquals( keys.length, map.size() );
assertTrue( "remove of element in set failed: " + set, set.remove( 42 ) );
assertEquals( keys.length - 1, set.size() );
assertEquals( keys.length - 1, map.size() );
try {
set.add( 42 );
fail( "Expected UnsupportedOperationException" );
}
catch ( UnsupportedOperationException ex ) {
// Expected
}
}
示例13: testKeySetRetainAllCollection
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRetainAllCollection() {
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] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.isEmpty() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
for ( int i = 0; i < keys.length; i++ ) {
java_set.add( Integer.valueOf( keys[i] ) );
}
assertFalse( set.retainAll( java_set ) );
assertEquals( keys.length, set.size() );
assertEquals( keys.length, map.size() );
for ( int i = 0; i < keys.length; i++ ) {
assertTrue( set.contains( keys[i] ) );
assertTrue( map.containsKey( keys[i] ) );
}
java_set.remove( 42 );
assertTrue( "set should have been modified: " + set + ", java: " + java_set,
set.retainAll( java_set ) );
assertEquals( keys.length - 1, set.size() );
assertEquals( keys.length - 1, map.size() );
for ( int i = 0; i < keys.length; i++ ) {
if ( keys[i] != 42 ) {
assertTrue( set.contains( keys[i] ) );
assertTrue( map.containsKey( keys[i] ) );
} else {
assertFalse( set.contains( keys[i] ) );
assertFalse( map.containsKey( keys[i] ) );
}
}
}
示例14: testKeySetRemoveAllCollection
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRemoveAllCollection() {
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] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.isEmpty() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
assertFalse( set.removeAll( java_set ) );
assertEquals( keys.length, set.size() );
assertEquals( keys.length, map.size() );
for ( int i = 0; i < keys.length; i++ ) {
assertTrue( set.contains( keys[i] ) );
assertTrue( map.containsKey( keys[i] ) );
}
for ( int i = 0; i < keys.length; i++ ) {
java_set.add( Integer.valueOf( keys[i] ) );
}
java_set.remove( 42 );
assertTrue( "set should have been modified: " + set + ", java: " + java_set,
set.removeAll( java_set ) );
assertEquals( "set: " + set, 1, set.size() );
assertEquals( "set: " + set, 1, map.size() );
for ( int i = 0; i < keys.length; i++ ) {
if ( keys[i] == 42 ) {
assertTrue( set.contains( keys[i] ) );
assertTrue( map.containsKey( keys[i] ) );
} else {
assertFalse( set.contains( keys[i] ) );
assertFalse( map.containsKey( keys[i] ) );
}
}
}
示例15: testKeySetRemoveAllCollection
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRemoveAllCollection() {
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] );
}
TIntSet set = map.keySet();
assertEquals( map.size(), set.size() );
assertFalse( set.isEmpty() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
assertFalse( set.removeAll( java_set ) );
assertEquals( keys.length, set.size() );
assertEquals( keys.length, map.size() );
for ( int i = 0; i < keys.length; i++ ) {
assertTrue( set.contains( keys[i] ) );
assertTrue( map.containsKey( keys[i] ) );
}
for ( int i = 0; i < keys.length; i++ ) {
java_set.add( Integer.valueOf( keys[i] ) );
}
java_set.remove( 42 );
assertTrue( "set should have been modified: " + set + ", java: " + java_set,
set.removeAll( java_set ) );
assertEquals( "set: " + set, 1, set.size() );
assertEquals( "set: " + set, 1, map.size() );
for ( int i = 0; i < keys.length; i++ ) {
if ( keys[i] == 42 ) {
assertTrue( set.contains( keys[i] ) );
assertTrue( map.containsKey( keys[i] ) );
} else {
assertFalse( set.contains( keys[i] ) );
assertFalse( map.containsKey( keys[i] ) );
}
}
}