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


Java Int2ObjectMap.int2ObjectEntrySet方法代码示例

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


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

示例1: IntMapGraph

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
public IntMapGraph(Int2ObjectMap<IntSet> map) {
	this.map = map;
	if (map.defaultReturnValue() == null || !map.defaultReturnValue().equals(IntSets.EMPTY_SET)) {
		LOGGER.warn("It is necessary to set default return value of the map as the empty set.");
		map.defaultReturnValue(IntSets.EMPTY_SET);
	}
	
	int maxNodeIndex = 0, numArcs = 0;
	for (Entry<IntSet> x : map.int2ObjectEntrySet()) {
		if (x.getIntKey() > maxNodeIndex)
			maxNodeIndex = x.getIntKey();
		for (int succ : x.getValue()) {
			if (succ > maxNodeIndex)
				maxNodeIndex = succ;
			numArcs++;
		}
	}
	
	this.numArcs  = numArcs;
	this.numNodes = maxNodeIndex+1;
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:22,代码来源:IntMapGraph.java

示例2: getWeightedRandomReversed

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
@Nullable
public static <T> T getWeightedRandomReversed(Random random, Int2ObjectMap<T> choices)
{
    long i = 0;
    IntSet ints = choices.keySet();
    for (IntIterator iterator = ints.iterator(); iterator.hasNext(); )
    {
        int x = iterator.nextInt();
        i += x;
    }
    i = getRandomLong(random, 0, i);
    for (Int2ObjectMap.Entry<T> entry : choices.int2ObjectEntrySet())
    {
        i -= entry.getIntKey();
        if (i < 0)
        {
            return entry.getValue();
        }
    }
    return null;
}
 
开发者ID:Diorite,项目名称:Diorite,代码行数:22,代码来源:DioriteRandomUtils.java

示例3: fastIterable

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
@Nonnull
public static <V> ObjectIterable<Int2ObjectMap.Entry<V>> fastIterable(
        @Nonnull final Int2ObjectMap<V> map) {
    final ObjectSet<Int2ObjectMap.Entry<V>> entries = map.int2ObjectEntrySet();
    return entries instanceof Int2ObjectMap.FastEntrySet ? new ObjectIterable<Int2ObjectMap.Entry<V>>() {
        public ObjectIterator<Int2ObjectMap.Entry<V>> iterator() {
            return ((Int2ObjectMap.FastEntrySet<V>) entries).fastIterator();
        }
    }
            : entries;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:12,代码来源:Fastutil.java

示例4: constructStarTree

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
private void constructStarTree(TreeNode node, int startDocId, int endDocId, int level) throws IOException {
  if (level == _dimensionsSplitOrder.size()) {
    return;
  }

  int splitDimensionId = _dimensionsSplitOrder.get(level);
  LOGGER.debug("Building tree at level: {} from startDoc: {} endDocId: {} splitting on dimension id: {}", level,
      startDocId, endDocId, splitDimensionId);

  int numDocs = endDocId - startDocId;
  Int2ObjectMap<IntPair> dimensionRangeMap;
  try (StarTreeDataTable dataTable = new StarTreeDataTable(
      new MMapBuffer(_dataFile, startDocId * _docSize, numDocs * _docSize, MMapMode.READ_ONLY), _dimensionSize,
      _metricSize, startDocId, endDocId)) {
    dimensionRangeMap = dataTable.groupOnDimension(startDocId, endDocId, splitDimensionId);
  }
  LOGGER.debug("Group stats:{}", dimensionRangeMap);

  node._childDimensionId = splitDimensionId;
  // Reserve one space for star node
  Map<Integer, TreeNode> children = new HashMap<>(dimensionRangeMap.size() + 1);
  node._children = children;
  for (Int2ObjectMap.Entry<IntPair> entry : dimensionRangeMap.int2ObjectEntrySet()) {
    int childDimensionValue = entry.getIntKey();
    TreeNode child = new TreeNode();
    _numNodes++;
    children.put(childDimensionValue, child);

    // The range pair value is the relative value to the start document id
    IntPair range = dimensionRangeMap.get(childDimensionValue);
    int childStartDocId = range.getLeft();
    child._startDocId = childStartDocId;
    int childEndDocId = range.getRight();
    child._endDocId = childEndDocId;

    if (childEndDocId - childStartDocId > _maxNumLeafRecords) {
      constructStarTree(child, childStartDocId, childEndDocId, level + 1);
    }
  }

  // Directly return if we don't need to create star-node
  if (_skipStarNodeCreationDimensions != null && _skipStarNodeCreationDimensions.contains(splitDimensionId)) {
    return;
  }

  // Create star node
  TreeNode starChild = new TreeNode();
  _numNodes++;
  children.put(StarTreeNode.ALL, starChild);
  starChild._dimensionId = splitDimensionId;
  starChild._dimensionValue = StarTreeNode.ALL;

  Iterator<Pair<DimensionBuffer, MetricBuffer>> iterator =
      getUniqueCombinations(startDocId, endDocId, splitDimensionId);
  int starChildStartDocId = _numRawDocs + _numAggregatedDocs;
  while (iterator.hasNext()) {
    Pair<DimensionBuffer, MetricBuffer> next = iterator.next();
    DimensionBuffer dimensions = next.getLeft();
    MetricBuffer metrics = next.getRight();
    appendToAggBuffer(dimensions, metrics);
  }
  _dataOutputStream.flush();
  int starChildEndDocId = _numRawDocs + _numAggregatedDocs;

  starChild._startDocId = starChildStartDocId;
  starChild._endDocId = starChildEndDocId;
  if (starChildEndDocId - starChildStartDocId > _maxNumLeafRecords) {
    constructStarTree(starChild, starChildStartDocId, starChildEndDocId, level + 1);
  }
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:71,代码来源:OffHeapStarTreeBuilder.java


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