當前位置: 首頁>>代碼示例>>Java>>正文


Java TObjectIntMap.put方法代碼示例

本文整理匯總了Java中gnu.trove.map.TObjectIntMap.put方法的典型用法代碼示例。如果您正苦於以下問題:Java TObjectIntMap.put方法的具體用法?Java TObjectIntMap.put怎麽用?Java TObjectIntMap.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gnu.trove.map.TObjectIntMap的用法示例。


在下文中一共展示了TObjectIntMap.put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildAccessors

import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
private static TObjectIntMap<String> buildAccessors(int accessFlags) {
    TObjectIntMap<String> map = new TObjectIntHashMap<>();
    map.put("public", Modifier.isPublic(accessFlags) ? 1 : 0);
    map.put("protected", Modifier.isProtected(accessFlags) ? 1 : 0);
    map.put("private", Modifier.isPrivate(accessFlags) ? 1 : 0);
    map.put("final", Modifier.isFinal(accessFlags) ? 1 : 0);
    map.put("interface", Modifier.isInterface(accessFlags) ? 1 : 0);
    map.put("native", Modifier.isNative(accessFlags) ? 1 : 0);
    map.put("static", Modifier.isStatic(accessFlags) ? 1 : 0);
    map.put("strict", Modifier.isStrict(accessFlags) ? 1 : 0);
    map.put("synchronized", Modifier.isSynchronized(accessFlags) ? 1 : 0);
    map.put("transient", Modifier.isTransient(accessFlags) ? 1 : 0);
    map.put("volatile", Modifier.isVolatile(accessFlags) ? 1 : 0);
    map.put("abstract", Modifier.isAbstract(accessFlags) ? 1 : 0);
    return map;
}
 
開發者ID:CalebFenton,項目名稱:apkfile,代碼行數:17,代碼來源:DexMethod.java

示例2: ignoreTestSerialize

import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
/**
 * Koloboke Compile doesn't support serialization yet
 */
@SuppressWarnings({"unchecked"})
public void ignoreTestSerialize() throws Exception {
    Integer[] keys = {1138, 42, 86, 99, 101, 727, 117};
    int[] vals = new int[keys.length];

    TObjectIntMap<Integer> map = withExpectedSize(10);
    for ( int i = 0; i < keys.length; i++ ) {
        vals[i] = keys[i] * 2;
        map.put( keys[i], vals[i] );
    }

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream( baos );
    oos.writeObject( map );

    ByteArrayInputStream bias = new ByteArrayInputStream( baos.toByteArray() );
    ObjectInputStream ois = new ObjectInputStream( bias );

    TObjectIntMap<Integer> deserialized = (TObjectIntMap<Integer>) ois.readObject();

    assertEquals( map, deserialized );
}
 
開發者ID:leventov,項目名稱:trove-over-koloboke-compile,代碼行數:26,代碼來源:TObjectPrimitiveHashMapTest.java

示例3: testTPrimitiveHashMap

import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public void testTPrimitiveHashMap() {
	TObjectIntMap<String> map = new TObjectIntHashMap<String>();

	// Add 5, remove the first four, repeat
	String[] to_remove = new String[ 4 ];
	int batch_index = 0;
	for( String s : Constants.STRING_OBJECTS ) {
		if ( batch_index < 4 ) {
			to_remove[ batch_index ] = s;
		}

		map.put( s, s.length() );
		batch_index++;

		if ( batch_index == 5 ) {
			for( String s_remove : to_remove ) {
				map.remove( s_remove );
			}
			batch_index = 0;
		}
	}
}
 
開發者ID:leventov,項目名稱:trove-over-koloboke-compile,代碼行數:23,代碼來源:ManyRemovalsBenchmark.java

示例4: testContainsKey

import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public void testContainsKey() {
    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] );
    }

    for ( int i = 0; i < element_count; i++ ) {
        assertTrue( "Key should be present: " + keys[i] + ", map: " + map,
                map.containsKey( keys[i] ) );
    }

    String key = "1138";
    assertFalse( "Key should not be present: " + key + ", map: " + map,
            map.containsKey( key ) );

    assertFalse( "Random object should not be present in map: " + map,
            map.containsKey( new Object() ) );
}
 
開發者ID:leventov,項目名稱:trove-over-koloboke-compile,代碼行數:25,代碼來源:TObjectPrimitiveMapDecoratorTest.java

示例5: testContainsValue

import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public void testContainsValue() {
    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] );
    }

    for ( int i = 0; i < element_count; i++ ) {
        assertTrue( "Value should be present: " + vals[i] + ", map: " + map,
                map.containsValue( vals[i] ) );
    }

    int val = 1138;
    assertFalse( "Key should not be present: " + val + ", map: " + map,
            map.containsValue( val ) );
}
 
開發者ID:leventov,項目名稱:trove-over-koloboke-compile,代碼行數:22,代碼來源:TObjectPrimitiveHashMapTest.java

示例6: testAdjustToNoEntry

import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public void testAdjustToNoEntry() {
	TObjectIntMap<String> map = TKolobokeObjectIntHashMap.withExpectedSize(10);
	
	assertEquals( 0, map.getNoEntryValue() );
	assertEquals( 0, map.get( "NotInThere" ) );
	
	map.put( "Value", 1 );
	assertEquals( 1, map.size() );
	assertEquals( 1, map.get( "Value" ) );
	assertTrue( map.containsKey( "Value" ) );
	assertTrue( map.containsValue( 1 ) );
	assertTrue( Arrays.equals( new int[] { 1 }, map.values() ) );
	
	map.adjustValue( "Value", -1 );
	assertEquals( 1, map.size() );
	assertEquals( 0, map.get( "Value" ) );
	assertTrue( map.containsKey( "Value" ) );
	assertTrue( map.containsValue( 0 ) );
	assertTrue( Arrays.equals( new int[] { 0 }, map.values() ) );
}
 
開發者ID:leventov,項目名稱:trove-over-koloboke-compile,代碼行數:21,代碼來源:NoEntryValueTest.java

示例7: testContainsValue

import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public void testContainsValue() {
    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] );
    }

    for ( int i = 0; i < element_count; i++ ) {
        assertTrue( "Value should be present: " + vals[i] + ", map: " + map,
                map.containsValue( vals[i] ) );
    }

    int val = 1138;
    assertFalse( "Key should not be present: " + val + ", map: " + map,
            map.containsValue( val ) );
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:22,代碼來源:TObjectPrimitiveHashMapTest.java

示例8: testAdjustValue

import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public void testAdjustValue() {
    TObjectIntMap<String> map = withExpectedSize(10);

    map.put( "one", 1 );

    boolean changed = map.adjustValue( "one", 1 );
    assertTrue( changed );
    assertEquals( 2, map.get( "one" ) );

    changed = map.adjustValue( "one", 5 );
    assertTrue( changed );
    assertEquals( 7, map.get( "one" ) );

    changed = map.adjustValue( "one", -3 );
    assertTrue( changed );
    assertEquals( 4, map.get( "one" ) );

    changed = map.adjustValue( "two", 1 );
    assertFalse( changed );
    assertFalse( map.containsKey( "two" ) );
}
 
開發者ID:leventov,項目名稱:trove-over-koloboke-compile,代碼行數:22,代碼來源:TObjectPrimitiveHashMapTest.java

示例9: testClear

import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public void testClear() {
    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() );

    map.clear();
    assertTrue( map.isEmpty() );
    assertEquals( 0, map.size() );

    assertEquals( map.getNoEntryValue(), map.get( keys[5] ) );
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:20,代碼來源:TObjectPrimitiveHashMapTest.java

示例10: testSerialize

import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
@SuppressWarnings({"unchecked"})
public void testSerialize() throws Exception {
    Integer[] keys = {1138, 42, 86, 99, 101, 727, 117};
    int[] vals = new int[keys.length];

    TObjectIntMap<Integer> map = new TObjectIntHashMap<Integer>();
    for ( int i = 0; i < keys.length; i++ ) {
        vals[i] = keys[i] * 2;
        map.put( keys[i], vals[i] );
    }

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream( baos );
    oos.writeObject( map );

    ByteArrayInputStream bias = new ByteArrayInputStream( baos.toByteArray() );
    ObjectInputStream ois = new ObjectInputStream( bias );

    TObjectIntMap<Integer> deserialized = (TObjectIntMap<Integer>) ois.readObject();

    assertEquals( map, deserialized );
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:23,代碼來源:TObjectPrimitiveHashMapTest.java

示例11: 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 ) );
}
 
開發者ID:leventov,項目名稱:trove-over-koloboke-compile,代碼行數:25,代碼來源:TObjectPrimitiveCustomHashMapTest.java

示例12: testClear

import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public void testClear() {
    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() );

    map.clear();
    assertTrue( map.isEmpty() );
    assertEquals( 0, map.size() );

    assertEquals( map.getNoEntryValue(), map.get( keys[5] ) );
}
 
開發者ID:leventov,項目名稱:trove-over-koloboke-compile,代碼行數:20,代碼來源:TObjectPrimitiveHashMapTest.java

示例13: splitAtrLine

import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public static TObjectIntMap<String> splitAtrLine(String line) {
    TObjectIntMap<String> atrPos = new TObjectIntHashMap<>();
    String[] atr = line.split(";");
    int index = 0;
    for (String a : atr) {
        atrPos.put(a, index);
        index++;
    }
    return atrPos;
}
 
開發者ID:graphium-project,項目名稱:graphium,代碼行數:11,代碼來源:ParserHelper.java

示例14: testConstructors

import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public void testConstructors() {
    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] );
    }

    TObjectIntHashMap<String> capacity =
            new TObjectIntHashMap<String>( 20 );
    for ( int i = 0; i < element_count; i++ ) {
        capacity.put( keys[i], vals[i] );
    }
    assertEquals( map, capacity );

    TObjectIntHashMap<String> cap_and_factor =
            new TObjectIntHashMap<String>( 20, 0.75f );
    for ( int i = 0; i < element_count; i++ ) {
        cap_and_factor.put( keys[i], vals[i] );
    }
    assertEquals( map, cap_and_factor );

    TObjectIntHashMap<String> fully_specified =
            new TObjectIntHashMap<String>( 20, 0.75f, Integer.MIN_VALUE );
    for ( int i = 0; i < element_count; i++ ) {
        fully_specified.put( keys[i], vals[i] );
    }
    assertEquals( map, fully_specified );

    TObjectIntHashMap<String> copy =
            new TObjectIntHashMap<String>( fully_specified );
    assertEquals( map, copy );
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:38,代碼來源:TObjectPrimitiveHashMapTest.java

示例15: testRemove

import gnu.trove.map.TObjectIntMap; //導入方法依賴的package包/類
public void testRemove() {
    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] );
    }

    for ( int i = 0; i < element_count; i++ ) {
        if ( i % 2 == 1 ) {
            assertEquals( "Remove should have modified map: " + keys[i] + ", map: " + map,
                    vals[i], map.remove( keys[i] ) );
        }
    }

    for ( int i = 0; i < element_count; i++ ) {
        if ( i % 2 == 1 ) {
            assertTrue( "Removed key still in map: " + keys[i] + ", map: " + map,
                    map.get( keys[i] ) == map.getNoEntryValue() );
        } else {
            assertTrue( "Key should still be in map: " + keys[i] + ", map: " + map,
                    map.get( keys[i] ) == vals[i] );
        }
    }
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:30,代碼來源:TObjectPrimitiveHashMapTest.java


注:本文中的gnu.trove.map.TObjectIntMap.put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。