当前位置: 首页>>代码示例>>Java>>正文


Java Int2IntMap.put方法代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.ints.Int2IntMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java Int2IntMap.put方法的具体用法?Java Int2IntMap.put怎么用?Java Int2IntMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在it.unimi.dsi.fastutil.ints.Int2IntMap的用法示例。


在下文中一共展示了Int2IntMap.put方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fillSeenPositions

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
private void fillSeenPositions(Collection<DexMethod> invokes) {
  for (DexMethod method : invokes) {
    DexType[] parameters = method.proto.parameters.values;
    int arity = parameters.length;
    int positions = computePositionsFor(method.proto, target, targetProtoCache, substituions);
    if (positions != 0) {
      Int2IntMap positionsMap =
          seenPositions.computeIfAbsent(method.name, k -> {
            Int2IntMap result = new Int2IntOpenHashMap();
            result.defaultReturnValue(NOT_FOUND);
            return result;
          });
      int value = 0;
      int previous = positionsMap.get(arity);
      if (previous != NOT_FOUND) {
        value = previous;
      }
      value |= positions;
      positionsMap.put(arity, value);
    }
  }

}
 
开发者ID:inferjay,项目名称:r8,代码行数:24,代码来源:SimpleClassMerger.java

示例2: renderLine

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
private static void renderLine(int regen, boolean low, int yTexture, int maxHealth, int maxExtraHearts, int current, int absorption, Gui gui, boolean highlight) {
    GlStateManager.pushMatrix();
    Int2IntMap map = new Int2IntArrayMap();
    if (low) {
        for (int i = 0; i < (maxHealth + maxExtraHearts); i++)
            map.put(i, EventHandler.rand.nextInt(2));
    }

    renderMax(regen, map, maxHealth, yTexture, gui, highlight);
    if (maxExtraHearts > 0) { //for absorption
        if (maxHealth != 0) {
            GlStateManager.translate(2 + 9 * maxHealth, 0, 0);
        }
        renderMax(regen - maxHealth, map, maxExtraHearts, yTexture, gui, false); //Do not highlight absorption
    }
    GlStateManager.popMatrix();
    GlStateManager.translate(0, 0, 1);

    renderCurrentHealth(regen, map, current, yTexture, gui);

    if (absorption > 0) {
        int offset = maxHealth * 9 + (maxHealth == 0 ? 0 : 2);
        GlStateManager.translate(offset, 0, 0);
        renderAbsorption(regen - maxHealth, map, absorption, yTexture, gui);
    }
}
 
开发者ID:ichttt,项目名称:FirstAid,代码行数:27,代码来源:GuiUtils.java

示例3: countByCategory

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
/**
 */
public Table countByCategory() {
    Table t = new Table("Column: " + name());
    CategoryColumn categories = new CategoryColumn("Category");
    IntColumn counts = new IntColumn("Count");

    Int2IntMap valueToCount = new Int2IntOpenHashMap();
    for (int next : values) {
        if (valueToCount.containsKey(next)) {
            valueToCount.put(next, valueToCount.get(next) + 1);
        } else {
            valueToCount.put(next, 1);
        }
    }

    for (Map.Entry<Integer, Integer> entry : valueToCount.int2IntEntrySet()) {
        categories.add(lookupTable.get(entry.getKey()));
        counts.append(entry.getValue());
    }
    t.addColumn(categories);
    t.addColumn(counts);
    return t;
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:25,代码来源:CategoryColumn.java

示例4: read

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
public static Int2IntMap read(File fname, String separator) {
	Int2IntMap cmtyMap = new Int2IntOpenHashMap();
	BufferedReader brd;
	try {
		brd = new BufferedReader(new FileReader(fname));
		String line;
		int node, cmtyId;
		String[] split;
		int nLines = 0;

		long startTime = System.currentTimeMillis();
		while( (line = brd.readLine()) != null ) {
			if( line.startsWith("#") || line.startsWith("%") )
				continue;

			nLines++;
			if( nLines > 0 & nLines % 1000000 == 0 )
				log.info("Reading "+nLines+" lines");

			split 	= line.split(separator);
			node 	= Integer.parseInt( split[0] );
			cmtyId 	= Integer.parseInt( split[1] );
			cmtyMap.put(node, cmtyId);
		}
		brd.close();
		long endTime = System.currentTimeMillis();
		log.info("Completed in "+(endTime-startTime)/1000.0+" s");
	} catch (Exception e) {
		e.printStackTrace();
	}
	return cmtyMap;
}
 
开发者ID:besil,项目名称:AuroraGraphManager,代码行数:33,代码来源:CommunityReader.java

示例5: getKeyForValue

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private int getKeyForValue(int value) {
  Int2IntMap map = (Int2IntMap) _groupKeyMap;
  int groupId = map.get(value);
  if (groupId == INVALID_ID) {
    groupId = _numGroupKeys;
    map.put(value, _numGroupKeys++);
  }
  return groupId;
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:11,代码来源:NoDictionarySingleColumnGroupKeyGenerator.java

示例6: map

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
/**
 * key, value, key, value, ...
 * pro parte maps have the parent usageKey as key, the pro parte usage key as value
 */
private static Int2IntMap map(int ... kvs) {
  Int2IntMap m = new Int2IntArrayMap(kvs.length / 2);
  int idx = 0;
  while (idx < kvs.length) {
    m.put(kvs[idx], kvs[idx+1]);
    idx = idx + 2;
  }
  return m;
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:14,代码来源:IdGeneratorTest.java

示例7: generateInitialOrdering

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
private IntList generateInitialOrdering(List<DifferenceSet> tempDiffSet) {

        IntList result = new IntArrayList();

        Int2IntMap counting = new Int2IntArrayMap();
        for (DifferenceSet ds : tempDiffSet) {

            int lastIndex = ds.getAttributes().nextSetBit(0);

            while (lastIndex != -1) {
                if (!counting.containsKey(lastIndex)) {
                    counting.put(lastIndex, 1);
                } else {
                    counting.put(lastIndex, counting.get(lastIndex) + 1);
                }
                lastIndex = ds.getAttributes().nextSetBit(lastIndex + 1);
            }
        }

        // TODO: Comperator und TreeMap --> Tommy
        while (true) {

            if (counting.size() == 0) {
                break;
            }

            int biggestAttribute = -1;
            int numberOfOcc = 0;
            for (int attr : counting.keySet()) {

                if (biggestAttribute < 0) {
                    biggestAttribute = attr;
                    numberOfOcc = counting.get(attr);
                    continue;
                }

                int tempOcc = counting.get(attr);
                if (tempOcc > numberOfOcc) {
                    numberOfOcc = tempOcc;
                    biggestAttribute = attr;
                } else if (tempOcc == numberOfOcc) {
                    if (biggestAttribute > attr) {
                        biggestAttribute = attr;
                    }
                }
            }

            if (numberOfOcc == 0) {
                break;
            }

            result.add(biggestAttribute);
            counting.remove(biggestAttribute);
        }

        return result;
    }
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:58,代码来源:FindCoversGenerator.java

示例8: generateNextOrdering

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
private IntList generateNextOrdering(List<DifferenceSet> next, IntList currentOrdering, int attribute) {

        IntList result = new IntArrayList();

        Int2IntMap counting = new Int2IntArrayMap();
        boolean seen = false;
        for (int i = 0; i < currentOrdering.size(); i++) {

            if (!seen) {
                if (currentOrdering.getInt(i) != attribute) {
                    continue;
                } else {
                    seen = true;
                }
            } else {

                counting.put(currentOrdering.getInt(i), 0);
                for (DifferenceSet ds : next) {

                    if (ds.getAttributes().get(currentOrdering.getInt(i))) {
                        counting.put(currentOrdering.getInt(i), counting.get(currentOrdering.getInt(i)) + 1);
                    }
                }
            }
        }

        // TODO: Comperator und TreeMap --> Tommy
        while (true) {

            if (counting.size() == 0) {
                break;
            }

            int biggestAttribute = -1;
            int numberOfOcc = 0;
            for (int attr : counting.keySet()) {

                if (biggestAttribute < 0) {
                    biggestAttribute = attr;
                    numberOfOcc = counting.get(attr);
                    continue;
                }

                int tempOcc = counting.get(attr);
                if (tempOcc > numberOfOcc) {
                    numberOfOcc = tempOcc;
                    biggestAttribute = attr;
                } else if (tempOcc == numberOfOcc) {
                    if (biggestAttribute > attr) {
                        biggestAttribute = attr;
                    }
                }
            }

            if (numberOfOcc == 0) {
                break;
            }

            result.add(biggestAttribute);
            counting.remove(biggestAttribute);
        }

        return result;
    }
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:65,代码来源:FindCoversGenerator.java

示例9: addNewSegment

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
/**
 * Note that some readers might still access the oldest segment for a while -- we do NOT interrupt
 * readers accessing the old segment. The expected behavior is that after a while though, none of
 * them will reference it anymore (once their computation finishes) and the JVM can then
 * garbage-collect it. This lagging reading behavior is what makes it hard to explicitly recycle
 * the already allocated memory so we need memory for k+1 segments (where k is the number of
 * segments we'll maintain).
 *
 * @param numEdgesInLiveSegment          is the number of edges in the current live segment
 * @param numEdgesInNonLiveSegmentsMap   contains a map from segment id to number of edges in it
 * @param statsReceiver                  is where the stats are updated
 * @param bipartiteGraphSegmentProvider  provides the new segment to be added
 * @return the live segment that was added
 */
public T addNewSegment(
    int numEdgesInLiveSegment,
    Int2IntMap numEdgesInNonLiveSegmentsMap,
    StatsReceiver statsReceiver,
    BipartiteGraphSegmentProvider<T> bipartiteGraphSegmentProvider
) {
  final Int2ObjectMap<T> segments =
      new Int2ObjectOpenHashMap<T>(multiSegmentReaderAccessibleInfo.getSegments());
  numEdgesInNonLiveSegmentsMap.put(liveSegmentId, numEdgesInLiveSegment);
  int oldestSegmentId = multiSegmentReaderAccessibleInfo.oldestSegmentId;
  // remove a segment if we're at the limit
  if (multiSegmentReaderAccessibleInfo.getSegments().size() == maxNumSegments) {
    segments.remove(oldestSegmentId);
    numEdgesInNonLiveSegmentsMap.remove(oldestSegmentId);
    LOG.info("Removed segment " + oldestSegmentId);
    oldestSegmentId++;
  } else {
    statsReceiver.counter("numSegments").incr();
  }
  int newLiveSegmentId =  multiSegmentReaderAccessibleInfo.liveSegmentId + 1;
  // add a new segment
  T liveSegment =
      bipartiteGraphSegmentProvider.generateNewSegment(newLiveSegmentId, maxNumEdgesPerSegment);
  segments.put(newLiveSegmentId, liveSegment);
  // now make the switch for the readers -- this is immediately published and visible!
  multiSegmentReaderAccessibleInfo = new MultiSegmentReaderAccessibleInfo<T>(
          segments, oldestSegmentId, newLiveSegmentId);

  // flush the write
  liveSegmentId = newLiveSegmentId;

  numEdgesInNonLiveSegments = 0;
  for (int segmentEdgeCount : numEdgesInNonLiveSegmentsMap.values()) {
    numEdgesInNonLiveSegments += segmentEdgeCount;
  }
  LOG.info("Total number of edges in graph = " + numEdgesInNonLiveSegments);
  LOG.info("Created a new segment: oldestSegmentId = " + oldestSegmentId
      + ", and liveSegmentId = " + liveSegmentId);

  return liveSegment;
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:56,代码来源:MultiSegmentReaderAccessibleInfoProvider.java


注:本文中的it.unimi.dsi.fastutil.ints.Int2IntMap.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。