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


Java Int2IntMap类代码示例

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


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

示例1: dot

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入依赖的package包/类
private double dot(SparseIntVector other) {
  double ret = 0;
  SparseIntVector baseVector = null;
  SparseIntVector streamVector = null;
  if(this.size() >= other.size()) {
    baseVector = new SparseIntVector(this);
    streamVector = other;
  } else {
    baseVector = new SparseIntVector(other);
    streamVector = this;
  }

  ObjectIterator<Int2IntMap.Entry> iter = streamVector.hashMap.int2IntEntrySet().fastIterator();
  Int2IntMap.Entry entry = null;
  while(iter.hasNext()) {
    entry = iter.next();
    if(baseVector.hashMap.containsKey(entry.getIntKey())) {
      ret += baseVector.hashMap.get(entry.getIntKey()) * entry.getIntValue();
    }
  }

  return ret;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:24,代码来源:SparseIntVector.java

示例2: serialize

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入依赖的package包/类
@Override
public void serialize(ByteBuf buf) {
  super.serialize(buf);
  part.serialize(buf);
  if(taskIndexToClockMap != null) {
    buf.writeInt(taskIndexToClockMap.size());
    ObjectIterator<Int2IntMap.Entry>
      iter = taskIndexToClockMap.int2IntEntrySet().fastIterator();
    Int2IntMap.Entry item;
    while(iter.hasNext()) {
      item = iter.next();
      buf.writeInt(item.getIntKey());
      buf.writeInt(item.getIntValue());
    }
  } else {
    buf.writeInt(0);
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:19,代码来源:RecoverPartRequest.java

示例3: toString

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入依赖的package包/类
private String toString(Int2IntOpenHashMap clocVec) {
  if(clocVec == null) {
    return "NULL";
  }

  StringBuilder sb = new StringBuilder();
  ObjectIterator<Int2IntMap.Entry> iter = clocVec.int2IntEntrySet().fastIterator();
  Int2IntMap.Entry item ;
  while(iter.hasNext()) {
    item = iter.next();
    sb.append(item.getIntKey());
    sb.append(":");
    sb.append(item.getIntValue());
    sb.append(";");
  }
  return sb.toString();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:18,代码来源:RecoverPartRequest.java

示例4: refreshMinClock

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入依赖的package包/类
private void refreshMinClock() {
  if (taskIndexToClockMap.size() < taskNum) {
    minClock = 0;
    return;
  }

  int min = Integer.MAX_VALUE;
  for (Int2IntMap.Entry entry : taskIndexToClockMap.int2IntEntrySet()) {
    if (entry.getIntValue() < min) {
      min = entry.getIntValue();
    }
  }

  if (minClock < min) {
    minClock = min;
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:18,代码来源:PartClockVector.java

示例5: setClockVec

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入依赖的package包/类
/**
 * Set clock vector
 * @param clockVec clock vector
 */
public void setClockVec(Int2IntOpenHashMap clockVec) {
  try {
    lock.writeLock().lock();
    ObjectIterator<Int2IntMap.Entry> iter = clockVec.int2IntEntrySet().fastIterator();
    Int2IntMap.Entry item;
    while(iter.hasNext()) {
      item = iter.next();
      if(!taskIndexToClockMap.containsKey(item.getIntKey())
        || (taskIndexToClockMap.containsKey(item.getIntKey())
        && taskIndexToClockMap.get(item.getIntKey()) < item.getIntValue())) {
        taskIndexToClockMap.put(item.getIntKey(), item.getIntValue());
      }
    }
    refreshMinClock();
  } finally {
    lock.writeLock().unlock();
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:23,代码来源:PartClockVector.java

示例6: adjustClocks

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入依赖的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

示例7: writeTo

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入依赖的package包/类
@Override
public void writeTo(DataOutputStream output) throws IOException {
  try {
    lock.readLock().lock();
    super.writeTo(output);
    output.writeInt(hashMap.size());

    ObjectIterator<Int2IntMap.Entry> iter = hashMap.int2IntEntrySet().fastIterator();
    Int2IntMap.Entry entry = null;
    while (iter.hasNext()) {
      entry = iter.next();
      output.writeInt(entry.getIntKey());
      output.writeInt(entry.getIntValue());
    }
  } finally {
    lock.readLock().unlock();
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:19,代码来源:ServerSparseIntRow.java

示例8: serialize

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入依赖的package包/类
@Override
public void serialize(ByteBuf buf) {
  try {
    lock.readLock().lock();
    super.serialize(buf);
    buf.writeInt(hashMap.size());

    ObjectIterator<Int2IntMap.Entry> iter = hashMap.int2IntEntrySet().fastIterator();
    Int2IntMap.Entry entry = null;
    while (iter.hasNext()) {
      entry = iter.next();
      buf.writeInt(entry.getIntKey());
      buf.writeInt(entry.getIntValue());
    }
  } finally {
    lock.readLock().unlock();
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:19,代码来源:ServerSparseIntRow.java

示例9: mergeTo

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入依赖的package包/类
/**
 * Merge this sparse int vector split to a index/value array
 * @param indexes index array
 * @param values value array
 * @param startPos write start position of the index/value array
 * @param len write length
 */
public void mergeTo(int[] indexes, int[] values, int startPos, int len) {
  try {
    lock.readLock().lock();
    int writeLen = len < hashMap.size() ? len : hashMap.size();
    if (writeLen == 0) {
      return;
    }

    int index = 0;
    ObjectIterator<Int2IntMap.Entry> iter = hashMap.int2IntEntrySet().fastIterator();
    Int2IntMap.Entry entry = null;
    while (iter.hasNext()) {
      entry = iter.next();
      indexes[startPos + index] = entry.getIntKey();
      values[startPos + index] = entry.getIntValue();
      index++;
      if (index == writeLen) {
        return;
      }
    }
  } finally {
    lock.readLock().unlock();
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:32,代码来源:ServerSparseIntRow.java

示例10: mergeParams

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入依赖的package包/类
private static Int2IntMap mergeParams(int[] params){
	if(params==null||params.length==0){
		CUSTOM_PARAMS.clear();
		CUSTOM_PARAMS.putAll(DEFAULT_PARAMS);
	}else{
		if(params.length%2!=0) throw new IllegalArgumentException("Params need to have x*2 elements!");
		CUSTOM_PARAMS.clear();
		CUSTOM_PARAMS.putAll(DEFAULT_PARAMS);
		for(int i=0, j=params.length/2;i<j;i++){
			int i1=i*2;
			CUSTOM_PARAMS.put(params[i1], params[i1+1]);
		}
	}
	
	return CUSTOM_PARAMS;
}
 
开发者ID:LapisSea,项目名称:OpenGL-Bullet-engine,代码行数:17,代码来源:TextureLoader.java

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

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

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

示例14: getFasterIntersectionMap

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入依赖的package包/类
private Int2IntMap getFasterIntersectionMap(int uidx) {
    Int2IntOpenHashMap intersectionMap = new Int2IntOpenHashMap();
    intersectionMap.defaultReturnValue(0);

    IntIterator iidxs = data.getUidxIidxs(uidx);
    while (iidxs.hasNext()) {
        IntIterator vidxs = data.getIidxUidxs(iidxs.nextInt());
        while (vidxs.hasNext()) {
            intersectionMap.addTo(vidxs.nextInt(), 1);
        }
    }

    intersectionMap.remove(uidx);

    return intersectionMap;
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:17,代码来源:SetSimilarity.java

示例15: findBestId

import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入依赖的package包/类
@Override
public final int findBestId(Predicate<WorldObject> predicate, World world) {
	int bestId = -1;
	int bestRelationshipValue = Integer.MIN_VALUE;
	for(Int2IntMap.Entry entry : idsToValue.int2IntEntrySet()) {
		int id = entry.getIntKey();
		int relationshipValue = entry.getIntValue();
		
		// id may not exist in world because it's filtered out by
		// WorldFacade, for example being invisible
		if (world.exists(id)) {
			WorldObject person = world.findWorldObjectById(id);
			
			if (relationshipValue > bestRelationshipValue && predicate.test(person)) {
				bestRelationshipValue = relationshipValue;
				bestId = id;
			}
		}
	}
	
	return bestId;
}
 
开发者ID:WorldGrower,项目名称:WorldGrower,代码行数:23,代码来源:AbstractIdMap.java


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