本文整理汇总了Java中gnu.trove.map.TIntLongMap.keys方法的典型用法代码示例。如果您正苦于以下问题:Java TIntLongMap.keys方法的具体用法?Java TIntLongMap.keys怎么用?Java TIntLongMap.keys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.TIntLongMap
的用法示例。
在下文中一共展示了TIntLongMap.keys方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBug2037709
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testBug2037709() {
TIntLongMap m = new TIntLongHashMap();
for ( int i = 0; i < 10; i++ ) {
m.put( i, i );
}
int sz = m.size();
assertEquals( 10, sz );
int[] keys = new int[sz];
m.keys( keys );
boolean[] seen = new boolean[sz];
Arrays.fill( seen, false );
for ( int i = 0; i < 10; i++ ) {
seen[keys[i]] = true;
}
for ( int i = 0; i < 10; i++ ) {
if ( !seen[i] ) {
TestCase.fail( "Missing key for: " + i );
}
}
}
示例2: testBug2037709
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testBug2037709() {
TIntLongMap m = new TIntLongOffheapHashMap();
for ( int i = 0; i < 10; i++ ) {
m.put( i, i );
}
int sz = m.size();
assertEquals( 10, sz );
int[] keys = new int[sz];
m.keys( keys );
boolean[] seen = new boolean[sz];
Arrays.fill( seen, false );
for ( int i = 0; i < 10; i++ ) {
seen[keys[i]] = true;
}
for ( int i = 0; i < 10; i++ ) {
if ( !seen[i] ) {
TestCase.fail( "Missing key for: " + i );
}
}
}
示例3: testKeys
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeys() {
TIntLongMap map = new TIntLongHashMap();
map.put( KEY_ONE, 10 );
map.put( KEY_TWO, 20 );
assertEquals( 2, map.size() );
int[] keys = map.keys( new int[map.size()] );
assertEquals( 2, keys.length );
TIntList keys_list = new TIntArrayList( keys );
assertTrue( keys_list.contains( KEY_ONE ) );
assertTrue( keys_list.contains( KEY_TWO ) );
int[] keys2 = map.keys();
assertEquals( 2, keys2.length );
TIntList keys_list2 = new TIntArrayList( keys2 );
assertTrue( keys_list2.contains( KEY_ONE ) );
assertTrue( keys_list2.contains( KEY_TWO ) );
int element_count = 20;
map = new TIntLongHashMap();
for ( int i = 0; i < element_count; i++ ) {
map.put( i, i * i );
}
assertEquals( element_count, map.size() );
keys = map.keys( new int[0] );
Arrays.sort( keys );
assertEquals( element_count, keys.length );
for ( int i = 0; i < element_count; i++ ) {
assertEquals( "expected: " + i + " got: " + keys[i] + ", i: " + i +
", keys: " + Arrays.toString( keys ), i, keys[i] );
assertEquals( i * i, map.get( keys[i] ) );
}
}
示例4: testKeys
import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeys() {
TIntLongMap map = new TIntLongOffheapHashMap();
map.put( KEY_ONE, 10 );
map.put( KEY_TWO, 20 );
assertEquals( 2, map.size() );
int[] keys = map.keys( new int[map.size()] );
assertEquals( 2, keys.length );
TIntList keys_list = new TIntArrayList( keys );
assertTrue( keys_list.contains( KEY_ONE ) );
assertTrue( keys_list.contains( KEY_TWO ) );
int[] keys2 = map.keys();
assertEquals( 2, keys2.length );
TIntList keys_list2 = new TIntArrayList( keys2 );
assertTrue( keys_list2.contains( KEY_ONE ) );
assertTrue( keys_list2.contains( KEY_TWO ) );
int element_count = 20;
map = new TIntLongOffheapHashMap();
for ( int i = 0; i < element_count; i++ ) {
map.put( i, i * i );
}
assertEquals( element_count, map.size() );
keys = map.keys( new int[0] );
Arrays.sort( keys );
assertEquals( element_count, keys.length );
for ( int i = 0; i < element_count; i++ ) {
assertEquals( "expected: " + i + " got: " + keys[i] + ", i: " + i +
", keys: " + Arrays.toString( keys ), i, keys[i] );
assertEquals( i * i, map.get( keys[i] ) );
}
}