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


Java TIntObjectMap類代碼示例

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


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

示例1: injectListener

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
@SuppressWarnings("unchecked")
private void injectListener(int version) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException {

	Field protocolsField = Protocol.LOGIN.TO_SERVER.getClass().getDeclaredField("protocols");
	protocolsField.setAccessible(true);
	TIntObjectMap<?> protocols = (TIntObjectMap)protocolsField.get(Protocol.LOGIN.TO_SERVER);

	Object protocolData = protocols.get(version);
	Field packetMapField = protocolData.getClass().getDeclaredField("packetMap");
	Field packetConstructorsField = protocolData.getClass().getDeclaredField("packetConstructors");
	packetMapField.setAccessible(true);
	packetConstructorsField.setAccessible(true);
	TObjectIntMap packetMap =  (TObjectIntMap)packetMapField.get(protocolData);
	TIntObjectMap packetConstructors =  (TIntObjectMap)packetConstructorsField.get(protocolData);

	packetMap.remove(EncryptionResponse.class);
	packetConstructors.remove(0x01);
	packetMap.put( EncryptionResponsePacket.class, 0x01);
	packetConstructors.put( 0x01, EncryptionResponsePacket.class.getDeclaredConstructor() );

	packetMapField.set(protocolData, packetMap);
	packetConstructorsField.set(protocolData, packetConstructors);
	protocolsField.set(Protocol.LOGIN.TO_SERVER, protocols);
}
 
開發者ID:frash23,項目名稱:onflie,代碼行數:25,代碼來源:Onflie.java

示例2: dfaToDkAutomaton

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
private static Automaton dfaToDkAutomaton(TIntObjectMap<State> map, Machine machine) {
	dk.brics.automaton.Automaton dkAut = new dk.brics.automaton.Automaton();
	APList aps = machine.getInAPs();
	
	for(int stateNr = 0; stateNr < machine.getStateSize(); stateNr ++) {
		State state = getState(map, stateNr);
		// initial states
		if(machine.getInitialState() == stateNr) {
			dkAut.setInitialState(state);
		}
		// final states
		if(machine.getAcceptance().isFinal(stateNr)) {
			state.setAccept(true);
		}

		for (int letter = 0; letter < aps.size(); letter ++) {
			int succ = machine.getSuccessor(stateNr, letter);
			State stateSucc = getState(map, succ);
			state.addTransition(new Transition(aps.get(letter).toString().charAt(0),
					stateSucc));
		}
	}
	
	dkAut.setDeterministic(true);
	return dkAut;
}
 
開發者ID:duckly,項目名稱:LearnMealyMachine,代碼行數:27,代碼來源:UtilMachine.java

示例3: createMesh

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
public void createMesh(List<Mesher> meshers, JmeResourceManager resourceManager) {
	Realm realm = chunk.getRealm();
	
	TIntObjectMap<Mesh> meshes = new TIntObjectHashMap<>();
	
	for (Mesher mesher : meshers) {
		meshes.putAll(mesher.buildMeshes(chunk));
	}
	
	geometries.clear();
	
	for (int key : meshes.keys()) {
		Block block = realm.getCosmos().getBlocks().get(key);
		
		Geometry geometry = new Geometry(chunk.toString() + ":" + block.getName(), meshes.get(key));
		geometry.setMaterial(resourceManager.getMaterial(block));
		geometry.setQueueBucket(Bucket.Transparent);
		
		geometries.add(geometry);
	}
}
 
開發者ID:quadracoatl,項目名稱:quadracoatl,代碼行數:22,代碼來源:ChunkSpatial.java

示例4: testSerialize

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
@SuppressWarnings({"unchecked"})
public void testSerialize() throws Exception {
    int element_count = 20;
    int[] keys = new int[element_count];
    String[] vals = new String[element_count];

    TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>();
    for (int i = 0; i < element_count; i++) {
        keys[i] = i + 1;
        vals[i] = Integer.toString(i + 1);
        raw_map.put(keys[i], vals[i]);
    }
    Map<Integer, String> map = TDecorators.wrap(raw_map);

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

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

    Map<Integer, String> deserialized = (Map<Integer, String>) ois.readObject();

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

示例5: testContainsKey

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
public void testContainsKey() {
    int element_count = 20;
    int[] keys = new int[element_count];
    String[] vals = new String[element_count];

    TIntObjectMap<String> map = new TIntObjectHashMap<String>();
    for ( int i = 0; i < element_count; i++ ) {
        keys[i] = i + 1;
        vals[i] = Integer.toString( 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] ) );
    }

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

示例6: testPutAllMap

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
public void testPutAllMap() {
    int element_count = 20;
    int[] keys = new int[element_count];
    String[] vals = new String[element_count];

    TIntObjectMap<String> control = new TIntObjectHashMap<String>();
    for ( int i = 0; i < element_count; i++ ) {
        keys[i] = i + 1;
        vals[i] = Integer.toString( i + 1 );
        control.put( keys[i], vals[i] );
    }

    TIntObjectMap<String> map = new TIntObjectHashMap<String>();

    Map<Integer, String> source = new HashMap<Integer, String>();
    for ( int i = 0; i < element_count; i++ ) {
        source.put( keys[i], vals[i] );
    }

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

示例7: testClear

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
public void testClear() {
    int element_count = 20;
    int[] keys = new int[element_count];
    String[] vals = new String[element_count];

    TIntObjectMap<String> map = new TIntObjectHashMap<String>();
    for ( int i = 0; i < element_count; i++ ) {
        keys[i] = i + 1;
        vals[i] = Integer.toString( i + 1 );
        map.put( keys[i], vals[i] );
    }
    assertEquals( element_count, map.size() );

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

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

示例8: testContainsKey

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
public void testContainsKey() {
    int element_count = 20;
    int[] keys = new int[element_count];
    String[] vals = new String[element_count];

    TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>();
    for (int i = 0; i < element_count; i++) {
        keys[i] = i + 1;
        vals[i] = Integer.toString(i + 1);
        raw_map.put(keys[i], vals[i]);
    }
    Map<Integer, String> map = TDecorators.wrap(raw_map);

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

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

示例9: testKeySetHashCode

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
public void testKeySetHashCode() {
    int element_count = 20;
    int[] keys = new int[element_count];
    String[] vals = new String[element_count];

    TIntObjectMap<String> map = new TIntObjectHashMap<String>();
    for ( int i = 0; i < element_count; i++ ) {
        keys[i] = i + 1;
        vals[i] = Integer.toString( i + 1 );
        map.put( keys[i], vals[i] );
    }
    assertEquals( element_count, map.size() );

    TIntSet keyset = map.keySet();
    for ( int i = 0; i < keyset.size(); i++ ) {
        assertTrue( keyset.contains( keys[i] ) );
    }
    assertFalse( keyset.isEmpty() );

    assertEquals( keyset.hashCode(), keyset.hashCode() );

    TIntSet other = new TIntHashSet( keys );
    other.add( 1138 );
    assertTrue( keyset.hashCode() != other.hashCode() );
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:26,代碼來源:TPrimitiveObjectHashMapTest.java

示例10: testTransformValues

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
public void testTransformValues() {
   int element_count = 20;
    int[] keys = new int[element_count];
    String[] vals = new String[element_count];

    TIntObjectMap<String> map =
            new TIntObjectHashMap<String>( element_count, 0.5f, Integer.MIN_VALUE );
    for ( int i = 0; i < element_count; i++ ) {
        keys[i] = i + 1;
        vals[i] = Integer.toString( i + 1 );
        map.put( keys[i], vals[i] );
    }
    assertEquals( element_count, map.size() );

    map.transformValues( new TObjectFunction<String,String>() {
        @Override
        public String execute( String value ) {
            return value + "/" + value;
        }
    } );

    for ( int i = 0; i < element_count; i++ ) {
        String expected = vals[i] + "/" + vals[i];
        assertEquals( expected, map.get( keys[i] ) );
    }
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:27,代碼來源:TPrimitiveObjectHashMapTest.java

示例11: testClear

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
public void testClear() {
    int element_count = 20;
    int[] keys = new int[element_count];
    String[] vals = new String[element_count];

    TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>();
    for (int i = 0; i < element_count; i++) {
        keys[i] = i + 1;
        vals[i] = Integer.toString(i + 1);
        raw_map.put(keys[i], vals[i]);
    }
    Map<Integer, String> map = TDecorators.wrap(raw_map);
    assertEquals(element_count, map.size());

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

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

示例12: testSerialize

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
@SuppressWarnings({"unchecked"})
public void testSerialize() throws Exception {
    int element_count = 20;
    int[] keys = new int[element_count];
    String[] vals = new String[element_count];

    TIntObjectMap<String> map = new TIntObjectHashMap<String>();
    for ( int i = 0; i < element_count; i++ ) {
        keys[i] = i + 1;
        vals[i] = Integer.toString( i + 1 );
        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 );

    TIntObjectMap<String> deserialized = (TIntObjectMap<String>) ois.readObject();

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

示例13: testPutAllMap

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
public void testPutAllMap() {
    int element_count = 20;
    int[] keys = new int[element_count];
    String[] vals = new String[element_count];

    TIntObjectMap<String> raw_control = new TIntObjectHashMap<String>();
    for (int i = 0; i < element_count; i++) {
        keys[i] = i + 1;
        vals[i] = Integer.toString(i + 1);
        raw_control.put(keys[i], vals[i]);
    }
    Map<Integer, String> control = TDecorators.wrap(raw_control);

    TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>();
    Map<Integer, String> map = TDecorators.wrap(raw_map);

    Map<Integer, String> source = new HashMap<Integer, String>();
    for (int i = 0; i < element_count; i++) {
        source.put(keys[i], vals[i]);
    }

    map.putAll(source);
    assertEquals(control, map);
}
 
開發者ID:leventov,項目名稱:trove-over-koloboke-compile,代碼行數:25,代碼來源:TPrimitiveObjectMapDecoratorTest.java

示例14: testContainsValue

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
public void testContainsValue() {
    int element_count = 20;
    int[] keys = new int[element_count];
    String[] vals = new String[element_count];

    TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>();
    for (int i = 0; i < element_count; i++) {
        keys[i] = i + 1;
        vals[i] = Integer.toString(i + 1);
        raw_map.put(keys[i], vals[i]);
    }
    Map<Integer, String> map = TDecorators.wrap(raw_map);

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

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

    //noinspection SuspiciousMethodCalls
    assertFalse("Random object should not be present in map: " + map,
            map.containsValue(new Object()));
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:27,代碼來源:TPrimitiveObjectMapDecoratorTest.java

示例15: testPutAll

import gnu.trove.map.TIntObjectMap; //導入依賴的package包/類
public void testPutAll() throws Exception {
    TIntObjectMap<String> raw_t = new TIntObjectHashMap<String>();
    Map<Integer, String> t = TDecorators.wrap(raw_t);
    TIntObjectMap<String> raw_m = new TIntObjectHashMap<String>();
    Map<Integer, String> m = TDecorators.wrap(raw_m);
    m.put(2, "one");
    m.put(4, "two");
    m.put(6, "three");

    t.put(5, "four");
    assertEquals(1, t.size());

    t.putAll(m);
    assertEquals(4, t.size());
    assertEquals("two", t.get(4));
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:17,代碼來源:TPrimitiveObjectMapDecoratorTest.java


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