Java 类gnu.trove.map.hash.TIntObjectHashMap 实例源码

项目:metanome-algorithms    文件:PartitionEquivalences.java   
public void addPartition(EquivalenceManagedPartition partition) {
    if (!this.observedPartitions.contains(partition.getIndices()) && !this.containsSimilarPartition(partition)) {
        this.observedPartitions.add(partition.getIndices());
        long hashNumber = partition.getHashNumber();
        System.out.println(String.format("Partition[%s]\t%d\tSize: %d", partition.getIndices(), hashNumber, partition.size()));
        partitionHashes.putIfAbsent(hashNumber, new TIntObjectHashMap<THashSet<EquivalenceManagedPartition>>());
        partitionHashes.get(hashNumber).putIfAbsent(partition.size(), new THashSet<EquivalenceManagedPartition>());
        THashSet<EquivalenceManagedPartition> partitionGroup = partitionHashes.get(hashNumber).get(partition.size());

        if (partitionGroup.isEmpty()) {
            partitionGroup.add(partition);
        } else {
            // then there is at least one element in the partitionGroup
            checkPossibleEquivalences(partitionGroup, partition);
        }
    }
}
项目:xcc    文件:CodeGenTypes.java   
public CodeGenTypes(HIRModuleGenerator moduleBuilder, TargetData td)
{
    builder = moduleBuilder;
    typeCaches = new HashMap<>();
    recordBeingLaidOut = new HashSet<>();
    functionBeingProcessed = new HashSet<>();
    deferredRecords = new LinkedList<>();
    recordDeclTypes = new HashMap<>();
    cgRecordLayout = new HashMap<>();
    fieldInfo = new HashMap<>();
    bitfields = new HashMap<>();
    context = moduleBuilder.getASTContext();
    target = context.target;
    theModule = moduleBuilder.getModule();
    targetData = td;
    pointersToResolve = new LinkedList<>();
    tagDeclTypes = new HashMap<>();
    functionTypes = new HashMap<>();
    functionInfos = new TIntObjectHashMap<>();
}
项目:CustomWorldGen    文件:ItemModelMesherForge.java   
public void register(Item item, int meta, ModelResourceLocation location)
{
    TIntObjectHashMap<ModelResourceLocation> locs = locations.get(item);
    TIntObjectHashMap<IBakedModel>           mods = models.get(item);
    if (locs == null)
    {
        locs = new TIntObjectHashMap<ModelResourceLocation>();
        locations.put(item, locs);
    }
    if (mods == null)
    {
        mods = new TIntObjectHashMap<IBakedModel>();
        models.put(item, mods);
    }
    locs.put(meta, location);
    mods.put(meta, getModelManager().getModel(location));
}
项目:quadracoatl    文件:ChunkSpatial.java   
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);
    }
}
项目:trove-3.0.3    文件:TPrimitiveObjectMapDecoratorTest.java   
public void testGet() {
    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(vals[10], map.get(Integer.valueOf(keys[10])));
    assertNull(map.get(Integer.valueOf(1138)));

    Integer key = Integer.valueOf(1138);
    map.put(key, null);
    assertTrue(map.containsKey(key));
    assertNull(map.get(key));

    Long long_key = Long.valueOf(1138);
    //noinspection SuspiciousMethodCalls
    assertNull(map.get(long_key));
}
项目:trove-3.0.3    文件:TPrimitiveObjectMapDecoratorTest.java   
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));
}
项目:trove-3.0.3    文件:TPrimitiveObjectMapDecoratorTest.java   
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()));
}
项目:trove-3.0.3    文件:TPrimitiveObjectMapDecoratorTest.java   
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);
}
项目:trove-3.0.3    文件:TPrimitiveObjectMapDecoratorTest.java   
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));
}
项目:trove-3.0.3    文件:TPrimitiveObjectMapDecoratorTest.java   
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]));
}
项目:trove-3.0.3    文件:TPrimitiveObjectMapDecoratorTest.java   
@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);
}
项目:MMServerEngine    文件:NetEventService.java   
public void init(){
    handlerMap = new HashMap<>();
    TIntObjectHashMap<Class<?>> netEventHandlerClassMap = ServiceHelper.getNetEventListenerHandlerClassMap();
    netEventHandlerClassMap.forEachEntry(new TIntObjectProcedure<Class<?>>() {
        @Override
        public boolean execute(int i, Class<?> aClass) {
            handlerMap.put(i, (NetEventListenerHandler) BeanHelper.getServiceBean(aClass));
            return true;
        }
    });

    selfAdd = Util.getHostAddress()+":"+Server.getEngineConfigure().getNetEventPort();


    monitorService = BeanHelper.getServiceBean(MonitorService.class);
    eventService = BeanHelper.getServiceBean(EventService.class);
    monitorService.addStartCondition(SysConstantDefine.NetEventServiceStart,
            "wait for netEvent start and connect mainServer");
}
项目:cineast    文件:DynamicGrid.java   
public DynamicGrid(T defaultElement, T[][] data){
  this(defaultElement);
  for(int x = 0; x < data.length; ++x){
    T[] arr = data[x];
    TIntObjectHashMap<T> map = new TIntObjectHashMap<>();
    for(int y = 0; y < arr.length; ++y){
      T element = arr[y];
      if(element != null){
        map.put(y, element);
      }
    }
    map.compact();
    grid.put(x, map);
  }
  grid.compact();
}
项目:trove-over-koloboke-compile    文件:TPrimitiveObjectMapDecoratorTest.java   
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));
}
项目:trove-over-koloboke-compile    文件:TPrimitiveObjectMapDecoratorTest.java   
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()));
}
项目:trove-over-koloboke-compile    文件:TPrimitiveObjectMapDecoratorTest.java   
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);
}
项目:trove-over-koloboke-compile    文件:TPrimitiveObjectMapDecoratorTest.java   
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));
}
项目:trove-over-koloboke-compile    文件:TPrimitiveObjectMapDecoratorTest.java   
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]));
}
项目:trove-over-koloboke-compile    文件:TPrimitiveObjectMapDecoratorTest.java   
@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);
}
项目:Carbon-2    文件:DataWatcherTransformer.java   
public static byte[] transform(WatchedEntity entity, byte[] data) throws IOException {
    if (entity == null) {
        return data;
    }
    TIntObjectMap<DataWatcherObject> objects = DataWatcherSerializer.decodeData(data);
    TIntObjectMap<DataWatcherObject> newobjects = new TIntObjectHashMap<DataWatcherObject>();
    //copy entity
    moveDWData(objects, newobjects, 0, 0); //flags
    moveDWData(objects, newobjects, 1, 1); //air
    moveDWData(objects, newobjects, 2, 2); //nametag
    moveDWData(objects, newobjects, 3, 3); //nametagvisible
    //copy specific types
    for (RemappingEntry entry : entity.getType().getRemaps()) {
        moveDWData(objects, newobjects, entry.getFrom(), entry.getTo());
    }
    return DataWatcherSerializer.encodeData(newobjects);
}
项目:openimaj    文件:TrendDetector.java   
public void setFeatureExtractor(TrendDetectorFeatureExtractor fe) {
    this.extractor = fe;
    final MersenneTwister rng = new MersenneTwister();

    final DoubleGaussianFactory gauss = new DoubleGaussianFactory(fe.nDimensions(), rng, w);
    final HashFunctionFactory<double[]> factory = new HashFunctionFactory<double[]>() {
        @Override
        public HashFunction<double[]> create() {
            return new LSBModifier<double[]>(gauss.create());
        }
    };

    sketcher = new IntLSHSketcher<double[]>(factory, nbits);
    database = new ArrayList<TIntObjectHashMap<Set<WriteableImageOutput>>>(
            sketcher.arrayLength());

    for (int i = 0; i < sketcher.arrayLength(); i++)
        database.add(new TIntObjectHashMap<Set<WriteableImageOutput>>());

}
项目:jbosen    文件:PsTableGroup.java   
private static TIntObjectMap<HostInfo> readHostInfos(String hostfile) {
    TIntObjectMap<HostInfo> hostMap = new TIntObjectHashMap<>();
    try {
        int idx = 0;
        Scanner scanner = new Scanner(new FileReader(hostfile));
        while (scanner.hasNext()) {
            String token = scanner.next();
            String[] parts = token.trim().split(":");
            Preconditions.checkArgument(parts.length == 2,
                    "Malformed token in host file: %s", token);
            hostMap.put(idx, new HostInfo(idx, parts[0], parts[1]));
            idx++;
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        System.exit(1);
    }
    return hostMap;
}
项目:lodreclib    文件:TextFileUtils.java   
public static void loadFileIndex(String file, TIntObjectHashMap<String> id_value){

    try{
        BufferedReader br = new BufferedReader(new FileReader(file));
        String line = null;

        while((line=br.readLine()) != null){
            String[] vals = line.split("\t");
            id_value.put(Integer.parseInt(vals[0]), vals[1]+":"+vals[2]);
        }

        br.close();
    }
    catch(Exception e){
        e.printStackTrace();
    }

}
项目:lodreclib    文件:TextFileUtils.java   
public static void loadIndex(String file, TIntObjectHashMap<String> id_value){

    try{
        BufferedReader br = new BufferedReader(new FileReader(file));
        String line = null;

        while((line=br.readLine()) != null){
            String[] vals = line.split("\t");
            id_value.put(Integer.parseInt(vals[0]), vals[1]);
        }

        br.close();
    }
    catch(Exception e){
        e.printStackTrace();
    }

}
项目:openimaj    文件:HoughCircles.java   
/**
 * Construct with the given parameters.
 * 
 * @param minRad
 *            minimum search radius
 * @param maxRad
 *            maximum search radius
 * @param radIncrement
 *            amount to increment search radius by between min and max.
 * @param nDegree
 *            number of degree increments
 */
public HoughCircles(int minRad, int maxRad, int radIncrement, int nDegree) {
    super();
    this.minRad = minRad;
    if (this.minRad <= 0)
        this.minRad = 1;
    this.maxRad = maxRad;
    this.radmap = new TIntObjectHashMap<TIntObjectHashMap<TIntFloatHashMap>>();
    this.radIncr = radIncrement;
    this.nRadius = (maxRad - minRad) / this.radIncr;
    this.nDegree = nDegree;
    this.cosanglemap = new float[nRadius][nDegree];
    this.sinanglemap = new float[nRadius][nDegree];
    for (int radIndex = 0; radIndex < this.nRadius; radIndex++) {
        for (int angIndex = 0; angIndex < nDegree; angIndex++) {
            final double ang = angIndex * (2 * PI / nDegree);
            final double rad = minRad + (radIndex * this.radIncr);
            this.cosanglemap[radIndex][angIndex] = (float) (rad * cos(ang));
            this.sinanglemap[radIndex][angIndex] = (float) (rad * sin(ang));
        }
    }
}
项目:lodreclib    文件:ItemPathExtractorWorker.java   
/**
 * Constuctor
 */
public ItemPathExtractorWorker(SynchronizedCounter counter,
                               TObjectIntHashMap<String> path_index, TIntObjectHashMap<String> inverse_path_index,
                               ItemTree main_item, ArrayList<ItemTree> items, TIntObjectHashMap<String> props_index, boolean inverseProps,
                               TextFileManager textWriter, StringFileManager pathWriter, boolean select_top_path,
                               TIntIntHashMap input_metadata_id, boolean computeInversePaths,
                               TIntObjectHashMap<TIntHashSet> items_link){

    this.counter = counter;
    this.path_index = path_index;
    this.main_item = main_item;
    this.items = items;
    this.props_index = props_index;
    this.inverseProps = inverseProps;
    this.textWriter = textWriter;
    this.pathWriter = pathWriter;
    this.select_top_path = select_top_path;
    this.input_metadata_id = input_metadata_id;
    this.computeInversePaths = computeInversePaths;
    this.items_link = items_link;
    this.inverse_path_index = inverse_path_index;
}
项目:openimaj    文件:HashingTest.java   
public HashingTest() {
    final MersenneTwister rng = new MersenneTwister();

    final DoubleGaussianFactory gauss = new DoubleGaussianFactory(ndims, rng, w);
    final HashFunctionFactory<double[]> factory = new HashFunctionFactory<double[]>() {
        @Override
        public HashFunction<double[]> create() {
            return new LSBModifier<double[]>(gauss.create());
        }
    };

    sketcher = new IntLSHSketcher<double[]>(factory, nbits);
    database = new ArrayList<TIntObjectHashMap<Set<String>>>(sketcher.arrayLength());

    for (int i = 0; i < sketcher.arrayLength(); i++)
        database.add(new TIntObjectHashMap<Set<String>>());
}
项目:evosuite    文件:JUnitCodeGenerator.java   
public JUnitCodeGenerator(final String cuName, final String packageName)
{
    if(cuName == null || cuName.isEmpty())
    {
        throw new IllegalArgumentException("Illegal compilation unit name: " + cuName);
    }

    if(packageName == null)
    {
        throw new NullPointerException("package name must not be null");
    }

    this.packageName = packageName;
    this.cuName = cuName;

    this.oidToVarMapping  = new TIntObjectHashMap<String>();
    this.oidToTypeMapping = new TIntObjectHashMap<Class<?>>();
    this.failedRecords    = new TIntHashSet();

    this.init();
}
项目:evosuite    文件:CodeGenerator.java   
public CodeGenerator(final CaptureLog log)
{
    if(log == null)
    {
        throw new NullPointerException();
    }

    this.log              = log.clone();
    this.oidToVarMapping  = new TIntObjectHashMap<String>();
    this.oidToTypeMapping = new TIntObjectHashMap<Class<?>>();
    this.varCounter       = 0;


    this.isNewInstanceMethodNeeded = false;
    this.isCallMethodMethodNeeded  = false;
    this.isSetFieldMethodNeeded    = false;
    this.isGetFieldMethodNeeded    = false;
    this.isXStreamNeeded           = false;
}
项目:wikit    文件:FeatureTransducer.java   
protected State (String name, int index, double initialWeight, double finalWeight,
                                 int[] inputs, int[] outputs, double[] weights,
                                 String[] destinationNames, FeatureTransducer transducer)
{
    assert (inputs.length == outputs.length
                    && inputs.length == weights.length
                    && inputs.length == destinationNames.length);
    this.transducer = transducer;
    this.name = name;
    this.index = index;
    this.initialWeight = initialWeight;
    this.finalWeight = finalWeight;
    this.transitions = new Transition[inputs.length];
    this.input2transitions = new TIntObjectHashMap();
    transitionCounts = null;
    for (int i = 0; i < inputs.length; i++) {
        // This constructor places the transtion into this.input2transitions
        transitions[i] = new Transition (inputs[i], outputs[i],
                                                                         weights[i], this, destinationNames[i]);
        transitions[i].index = i;
    }
}
项目:gnu.trove    文件:TPrimitiveObjectMapDecoratorTest.java   
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));
}
项目:gnu.trove    文件:TPrimitiveObjectMapDecoratorTest.java   
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()));
}
项目:gnu.trove    文件:TPrimitiveObjectMapDecoratorTest.java   
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);
}
项目:gnu.trove    文件:TPrimitiveObjectMapDecoratorTest.java   
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));
}
项目:gnu.trove    文件:TPrimitiveObjectMapDecoratorTest.java   
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]));
}
项目:gnu.trove    文件:TPrimitiveObjectMapDecoratorTest.java   
@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);
}
项目:wikit    文件:TRP.java   
protected void initForGraph (FactorGraph m)
{
  super.initForGraph (m);

  int numNodes = m.numVariables ();
  factorTouched = new TIntObjectHashMap (numNodes);
  hasConverged = false;

  if (factory == null) {
    factory = new AlmostRandomTreeFactory ();
  }

  if (terminator == null) {
    terminator = new DefaultConvergenceTerminator ();
  } else {
    terminator.reset ();
  }
}
项目:xcc    文件:LLParser.java   
public LLParser(MemoryBuffer buf, SourceMgr smg, Module m, OutParamWrapper<SMDiagnostic> diag)
{
    lexer = new LLLexer(buf, smg, diag);
    this.m = m;
    forwardRefTypes = new TreeMap<>();
    forwardRefTypeIDs = new TIntObjectHashMap<>();
    numberedTypes = new ArrayList<>();
    metadataCache = new TIntObjectHashMap<>();
    forwardRefMDNodes = new TIntObjectHashMap<>();
    upRefs = new ArrayList<>();
    forwardRefVals = new TreeMap<>();
    forwardRefValIDs = new TIntObjectHashMap<>();
    numberedVals = new ArrayList<>();
}
项目:morpheus-core    文件:SparseArrayOfObjects.java   
/**
 * Constructor
 * @param type      the type for this array
 * @param length    the length for this array
 * @param defaultValue  the default value
 */
SparseArrayOfObjects(Class<T> type, int length, T defaultValue) {
    super(type, ArrayStyle.SPARSE, false);
    this.length = length;
    this.defaultValue = defaultValue;
    this.values = new TIntObjectHashMap<>((int)Math.max(length * 0.5, 10d), 0.8f, -1);
}
项目:CustomWorldGen    文件:ItemModelMesherForge.java   
public void rebuildCache()
{
    final ModelManager manager = this.getModelManager();
    for (Map.Entry<Item, TIntObjectHashMap<ModelResourceLocation>> e : locations.entrySet())
    {
        TIntObjectHashMap<IBakedModel> mods = models.get(e.getKey());
        if (mods != null)
        {
            mods.clear();
        }
        else
        {
            mods = new TIntObjectHashMap<IBakedModel>();
            models.put(e.getKey(), mods);
        }
        final TIntObjectHashMap<IBakedModel> map = mods;
        e.getValue().forEachEntry(new TIntObjectProcedure<ModelResourceLocation>()
        {
            @Override
            public boolean execute(int meta, ModelResourceLocation location)
            {
                map.put(meta, manager.getModel(location));
                return true;
            }
        });
    }
}