当前位置: 首页>>代码示例>>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;未经允许,请勿转载。