本文整理匯總了Java中gnu.trove.map.TObjectIntMap.keySet方法的典型用法代碼示例。如果您正苦於以下問題:Java TObjectIntMap.keySet方法的具體用法?Java TObjectIntMap.keySet怎麽用?Java TObjectIntMap.keySet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gnu.trove.map.TObjectIntMap
的用法示例。
在下文中一共展示了TObjectIntMap.keySet方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testArray
import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public void testArray() {
char[] foo = new char[] { 'a', 'b', 'c' };
char[] bar = new char[] { 'a', 'b', 'c' };
assertFalse( foo.hashCode() == bar.hashCode() );
//noinspection ArrayEquals
assertFalse( foo.equals( bar ) );
HashingStrategy<char[]> strategy = new ArrayHashingStrategy();
assertTrue( strategy.computeHashCode( foo ) ==
strategy.computeHashCode( bar ) );
assertTrue( strategy.equals( foo, bar ) );
TObjectIntMap<char[]> map = new TObjectIntCustomHashMap<char[]>( strategy );
map.put( foo, 12 );
assertTrue( map.containsKey( foo ) );
assertTrue( map.containsKey( bar ) );
assertEquals( 12, map.get( foo ) );
assertEquals( 12, map.get( bar ) );
Set<char[]> keys = map.keySet();
assertTrue( keys.contains( foo ) );
assertTrue( keys.contains( bar ) );
}
示例2: convertToJava
import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public static Map<Object, Object> convertToJava(TObjectIntMap map) {
Map<Object, Object> javaMap = new HashMap<>();
for (Object key : map.keySet()) {
javaMap.put(key, map.get(key));
}
return javaMap;
}
示例3: rollUp
import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public static void rollUp(TObjectIntMap dest, TObjectIntMap src) {
for (Object key : src.keySet()) {
int value = src.get(key);
dest.adjustOrPutValue(key, value, value);
}
}
示例4: testSerialization
import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public void testSerialization() throws Exception {
char[] foo = new char[] { 'a', 'b', 'c' };
char[] bar = new char[] { 'a', 'b', 'c' };
HashingStrategy<char[]> strategy = new ArrayHashingStrategy();
TObjectIntMap<char[]> map = new TObjectIntCustomHashMap<char[]>( strategy );
map.put( foo, 33 );
// Make sure it still works after being serialized
ObjectOutputStream oout = null;
ByteArrayOutputStream bout = null;
ObjectInputStream oin = null;
ByteArrayInputStream bin = null;
try {
bout = new ByteArrayOutputStream();
oout = new ObjectOutputStream( bout );
oout.writeObject( map );
bin = new ByteArrayInputStream( bout.toByteArray() );
oin = new ObjectInputStream( bin );
map = ( TObjectIntMap<char[]> ) oin.readObject();
}
finally {
if ( oin != null ) oin.close();
if ( bin != null ) bin.close();
if ( oout != null ) oout.close();
if ( bout != null ) bout.close();
}
assertTrue( map.containsKey( foo ) );
assertTrue( map.containsKey( bar ) );
assertEquals( 33, map.get( foo ) );
assertEquals( 33, map.get( bar ) );
Set<char[]> keys = map.keySet();
assertTrue( keys.contains( foo ) );
assertTrue( keys.contains( bar ) );
}