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


Java Int2ObjectMap类代码示例

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


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

示例1: adjustClocks

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入依赖的package包/类
/**
 * Adjust clock values
 * @param taskToMatrixClocks taskId->(matrixId->clock) map
 */
public void adjustClocks(Int2ObjectOpenHashMap<Int2IntOpenHashMap> taskToMatrixClocks) {
  ObjectIterator<Int2ObjectMap.Entry<Int2IntOpenHashMap>> taskIter =
    taskToMatrixClocks.int2ObjectEntrySet().fastIterator();
  Int2ObjectMap.Entry<Int2IntOpenHashMap> taskEntry = null;
  int taskId = 0;
  Int2IntOpenHashMap matrixIdToClockMap = null;
  ObjectIterator<Int2IntMap.Entry> matrixIter = null;
  Int2IntMap.Entry matrixEntry = null;

  while(taskIter.hasNext()) {
    taskEntry = taskIter.next();
    taskId = taskEntry.getIntKey();
    matrixIdToClockMap = taskEntry.getValue();
    matrixIter = matrixIdToClockMap.int2IntEntrySet().fastIterator();
    while (matrixIter.hasNext()) {
      matrixEntry = matrixIter.next();
      updateClock(matrixEntry.getIntKey(), taskId, matrixEntry.getIntValue());
    }
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:25,代码来源:ClockVectorManager.java

示例2: init

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入依赖的package包/类
protected static Entry<Map<String, SimpleEnum<?>>, Int2ObjectMap<SimpleEnum<?>>> init(final Class<?> clazz, final int size)
{
    Map<String, SimpleEnum<?>> byName = ASimpleEnum.byName.get(clazz);
    if (byName == null)
    {
        byName = new CaseInsensitiveMap<>(size, SMALL_LOAD_FACTOR);
        ASimpleEnum.byName.put(clazz, byName);
    }
    Int2ObjectMap<SimpleEnum<?>> byID = ASimpleEnum.byOrdinal.get(clazz);
    if (byID == null)
    {
        byID = new Int2ObjectOpenHashMap<>(size, SMALL_LOAD_FACTOR);
        ASimpleEnum.byOrdinal.put(clazz, byID);
    }
    return new SimpleEntry<>(byName, byID);
}
 
开发者ID:Diorite,项目名称:Diorite-old,代码行数:17,代码来源:SimpleEnum.java

示例3: predict

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入依赖的package包/类
private static double predict(final int user, final int itemI,
        @Nonnull final Int2ObjectMap<Int2FloatMap> knnItems, final int excludeIndex,
        @Nonnull final FloatMatrix weightMatrix) {
    final Int2FloatMap kNNu = knnItems.get(user);
    if (kNNu == null) {
        return 0.d;
    }

    double pred = 0.d;
    for (Int2FloatMap.Entry e : Fastutil.fastIterable(kNNu)) {
        final int itemK = e.getIntKey();
        if (itemK == excludeIndex) {
            continue;
        }
        float ruk = e.getFloatValue();
        pred += ruk * weightMatrix.get(itemI, itemK, 0.d);
    }
    return pred;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:20,代码来源:SlimUDTF.java

示例4: replayTrain

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入依赖的package包/类
private void replayTrain(@Nonnull final ByteBuffer buf) {
    final int itemI = buf.getInt();
    final int knnSize = buf.getInt();

    final Int2ObjectMap<Int2FloatMap> knnItems = new Int2ObjectOpenHashMap<>(1024);
    final IntSet pairItems = new IntOpenHashSet();
    for (int i = 0; i < knnSize; i++) {
        int user = buf.getInt();
        int ruSize = buf.getInt();
        Int2FloatMap ru = new Int2FloatOpenHashMap(ruSize);
        ru.defaultReturnValue(0.f);

        for (int j = 0; j < ruSize; j++) {
            int itemK = buf.getInt();
            pairItems.add(itemK);
            float ruk = buf.getFloat();
            ru.put(itemK, ruk);
        }
        knnItems.put(user, ru);
    }

    for (int itemJ : pairItems) {
        train(itemI, knnItems, itemJ);
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:26,代码来源:SlimUDTF.java

示例5: kNNentries

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入依赖的package包/类
@Nonnull
private static Int2ObjectMap<Int2FloatMap> kNNentries(@Nonnull final Object kNNiObj,
        @Nonnull final MapObjectInspector knnItemsOI,
        @Nonnull final PrimitiveObjectInspector knnItemsKeyOI,
        @Nonnull final MapObjectInspector knnItemsValueOI,
        @Nonnull final PrimitiveObjectInspector knnItemsValueKeyOI,
        @Nonnull final PrimitiveObjectInspector knnItemsValueValueOI,
        @Nullable Int2ObjectMap<Int2FloatMap> knnItems, @Nonnull final MutableInt nnzKNNi) {
    if (knnItems == null) {
        knnItems = new Int2ObjectOpenHashMap<>(1024);
    } else {
        knnItems.clear();
    }

    int numElementOfKNNItems = 0;
    for (Map.Entry<?, ?> entry : knnItemsOI.getMap(kNNiObj).entrySet()) {
        int user = PrimitiveObjectInspectorUtils.getInt(entry.getKey(), knnItemsKeyOI);
        Int2FloatMap ru = int2floatMap(knnItemsValueOI.getMap(entry.getValue()),
            knnItemsValueKeyOI, knnItemsValueValueOI);
        knnItems.put(user, ru);
        numElementOfKNNItems += ru.size();
    }

    nnzKNNi.setValue(numElementOfKNNItems);
    return knnItems;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:27,代码来源:SlimUDTF.java

示例6: pairToEntry

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入依赖的package包/类
public static Int2ObjectMap.Entry pairToEntry(final IntObjectPair pair) {
  return new Int2ObjectMap.Entry() {
    @Override
    public int getIntKey() {
      return pair.getFirstInt();
    }

    @Override
    public Object getKey() {
      return pair.getFirst();
    }

    @Override
    public Object getValue() {
      return pair.getSecond();
    }

    @Override
    public Object setValue(Object value) {
      throw new UnsupportedOperationException("This entry is immutable");
    }
  };
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:TuplesUtil.java

示例7: initialize

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入依赖的package包/类
private int initialize(Int2ObjectMap<CustomTimeBucket> idToTimeBucket)
{
  Preconditions.checkNotNull(idToTimeBucket);

  int tempId = Integer.MIN_VALUE;

  for (int timeBucketId : idToTimeBucket.keySet()) {
    tempId = Math.max(tempId, timeBucketId);
    CustomTimeBucket customTimeBucket = idToTimeBucket.get(timeBucketId);
    textToTimeBucket.put(customTimeBucket.getText(), customTimeBucket);
    Preconditions.checkNotNull(customTimeBucket);
    timeBucketToId.put(customTimeBucket, timeBucketId);
  }

  return tempId;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:17,代码来源:CustomTimeBucketRegistry.java

示例8: buildNonCompositeAggregatorIDMap

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入依赖的package包/类
protected void buildNonCompositeAggregatorIDMap(String aggregatorName, FieldsDescriptor inputDescriptor,
    IntArrayList aggIDList, Int2ObjectMap<FieldsDescriptor> inputMap, Int2ObjectMap<FieldsDescriptor> outputMap)
{
  IncrementalAggregator incrementalAggregator = aggregatorRegistry.getNameToIncrementalAggregator().get(
      aggregatorName);
  //don't need to build OTF aggregate
  if (incrementalAggregator == null) {
    return;
  }
  int aggregatorID = aggregatorRegistry.getIncrementalAggregatorNameToID().get(aggregatorName);
  mergeAggregatorID(aggIDList, aggregatorID);
  inputMap.put(aggregatorID, inputDescriptor);
  outputMap.put(aggregatorID,
      AggregatorUtils.getOutputFieldsDescriptor(inputDescriptor,
      incrementalAggregator));
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:17,代码来源:DimensionalConfigurationSchema.java

示例9: 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

示例10: LatentMatrixEstimator

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入依赖的package包/类
public LatentMatrixEstimator(ImmutableGraph graph, Int2ObjectMap<IntSet> node2cat, String output, Matrix initialMatrix) {
	
	rnd = RandomSingleton.get();
	pl = new ProgressLogger(LOGGER, "node couples");
	
	this.graph = graph;
	this.node2cat = node2cat;
	if (graph.numNodes() != node2cat.size()) {
		LOGGER.warn("node2cat file and graph file have a different number of nodes: " +
				"respectively, " + node2cat.size() + " and " + graph.numNodes());
	}
	
	numNodes = graph.numNodes();
	
	classifier = new PAClassifier(initialMatrix);
	this.output = output;
	nArcsLearned = 0;
	
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:20,代码来源:LatentMatrixEstimator.java

示例11: PooledDatasetChecker

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入依赖的package包/类
public PooledDatasetChecker(GroundTruth evaluations, ImmutableGraph g, UnexpectednessScorer[] pool, Int2ObjectMap<String> id2name) throws IOException {
	this.graph = g;
	this.pool = pool;
	this.evaluations = evaluations;
	this.id2name = id2name;
	SummaryStatistics[] stats = new SummaryStatistics[pool.length];
	for (int i = 0; i < stats.length; i++)
		stats[i] = new SummaryStatistics();
	retriever2itsFraction = new Object2ObjectOpenHashMap<UnexpectednessScorer, SummaryStatistics>(pool, stats);
	for (int i = 0; i < stats.length; i++)
		stats[i] = new SummaryStatistics();
	retriever2evaluatedTopResults = new Object2ObjectOpenHashMap<UnexpectednessScorer, SummaryStatistics>(pool, stats);
	unmatchStats = new SummaryStatistics();

	System.out.println(evaluations.stats());
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:17,代码来源:PooledDatasetChecker.java

示例12: 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

示例13: get

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入依赖的package包/类
public Vector get(int index) {
    int count = 0;
    ObjectIterator<Int2ObjectMap.Entry<LocalBlockVectorSet>> iter = localSets.int2ObjectEntrySet().iterator();
    while (iter.hasNext()) {
        Int2ObjectMap.Entry<LocalBlockVectorSet> entry = iter.next();
        LocalBlockVectorSet set = entry.getValue();
        int size = set.size();
        int newSize = count + size;
        if (newSize > index) {
            int localIndex = index - count;
            Vector pos = set.getIndex(localIndex);
            if (pos != null) {
                int pair = entry.getIntKey();
                int cx = MathMan.unpairX(pair);
                int cz = MathMan.unpairY(pair);
                pos.mutX((cx << 11) + pos.getBlockX());
                pos.mutZ((cz << 11) + pos.getBlockZ());
                return pos;
            }
        }
        count += newSize;
    }
    return null;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:25,代码来源:BlockVectorSet.java

示例14: calculateLayerArrays

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入依赖的package包/类
protected void calculateLayerArrays() {
    Int2ObjectOpenHashMap<char[]> colorLayerMap = new Int2ObjectOpenHashMap<>();
    for (int i = 0; i < validBlockIds.length; i++) {
        int color = validColors[i];
        int combined = validBlockIds[i];
        if (hasAlpha(color)) {
            for (int j = 0; j < validBlockIds.length; j++) {
                int colorOther = validColors[j];
                if (!hasAlpha(colorOther)) {
                    int combinedOther = validBlockIds[j];
                    int combinedColor = combineTransparency(color, colorOther);
                    colorLayerMap.put(combinedColor, new char[]{(char) combined, (char) combinedOther});
                }
            }
        }
    }
    this.validLayerColors = new int[colorLayerMap.size()];
    this.validLayerBlocks = new char[colorLayerMap.size()][];
    int index = 0;
    for (Int2ObjectMap.Entry<char[]> entry : colorLayerMap.int2ObjectEntrySet()) {
        validLayerColors[index] = entry.getIntKey();
        validLayerBlocks[index++] = entry.getValue();
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:25,代码来源:TextureUtil.java

示例15: makeDependency

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入依赖的package包/类
private Dependency makeDependency(JCas aJCas, int govId, int depId, String label, String flavor,
        Int2ObjectMap<Token> tokens, String[] word)
{
    Dependency rel = new Dependency(aJCas);
    if (govId == 0) {
        rel.setGovernor(tokens.get(depId));
        rel.setDependent(tokens.get(depId));
    }
    else {
        rel.setGovernor(tokens.get(govId));
        rel.setDependent(tokens.get(depId));
    }

    rel.setDependencyType(label);
    // This is set via FSUtil because we still use the DKPro Core 1.7.0 JCas classes
    FSUtil.setFeature(rel, "flavor", flavor);
    rel.setBegin(rel.getDependent().getBegin());
    rel.setEnd(rel.getDependent().getEnd());
    rel.addToIndexes();

    return rel;
}
 
开发者ID:webanno,项目名称:webanno,代码行数:23,代码来源:ConllUReader.java


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