gnu.trove.map.TIntIntMap类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中gnu.trove.map.TIntIntMap类的一些代码示例,展示了TIntIntMap类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TIntIntMap类的具体详情如下:
包路径:gnu.trove.map.TIntIntMap
类名称:TIntIntMap

TIntIntMap介绍

[英]Interface for a primitive map of int keys and int values.
[中]用于int键和int值的基本映射的接口。

代码示例

代码示例来源:origin: alibaba/mdrill

/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
  if ( ! ( other instanceof TIntIntMap ) ) {
    return false;
  }
  TIntIntMap that = ( TIntIntMap ) other;
  if ( that.size() != this.size() ) {
    return false;
  }
  int[] values = _values;
  byte[] states = _states;
  int this_no_entry_value = getNoEntryValue();
  int that_no_entry_value = that.getNoEntryValue();
  for ( int i = values.length; i-- > 0; ) {
    if ( states[i] == FULL ) {
      int key = _set[i];
      int that_value = that.get( key );
      int this_value = values[i];
      if ( ( this_value != that_value ) &&
         ( this_value != this_no_entry_value ) &&
         ( that_value != that_no_entry_value ) ) {
        return false;
      }
    }
  }
  return true;
}

代码示例来源:origin: CalebFenton/simplify

private void checkMaxVisits(ExecutionNode node, VirtualMethod localMethod, TIntIntMap addressToVisitCount) throws MaxAddressVisitsExceededException, MaxMethodVisitsExceededException {
  if (totalVisits > getMaxMethodVisits()) {
    throw new MaxMethodVisitsExceededException(node, localMethod.getSignature());
  }
  int address = node.getAddress();
  int visitCount = addressToVisitCount.get(address);
  if (visitCount > getMaxAddressVisits()) {
    throw new MaxAddressVisitsExceededException(node, localMethod.getSignature());
  }
  boolean adjusted = addressToVisitCount.adjustValue(address, 1);
  if (!adjusted) {
    addressToVisitCount.put(address, 1);
  }
}

代码示例来源:origin: alibaba/mdrill

/**
 * Checks for the present of <tt>key</tt> in the keys of the map.
 *
 * @param key an <code>Object</code> value
 * @return a <code>boolean</code> value
 */
public boolean containsKey( Object key ) {
  if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
  return key instanceof Integer && _map.containsKey( unwrapKey( key ) );
}

代码示例来源:origin: CalebFenton/simplify

@Override
public String toString() {
  StringBuilder sb = new StringBuilder(getName());
  sb.append(" [");
  int[] keys = targetKeyToOffset.keys();
  Arrays.sort(keys);
  for (int key : keys) {
    int offset = targetKeyToOffset.get(key);
    sb.append(key).append(" -> :addr_").append(offset).append(", ");
  }
  sb.setLength(sb.length() - 2);
  sb.append(']');
  return sb.toString();
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

for (Stop stop : pattern.getStops()) {
    int vidx = graph.index.stopVertexForStop.get(stop).getIndex();
    int stopIndex = indexForStop.get(vidx);
    if (stopIndex == -1) {
      stopIndex = indexForStop.size();
      indexForStop.put(vidx, stopIndex);
      stopForIndex.add(vidx);
      stopNames.add(stop.getName());
    indexForStop.put(t.index, stopIndex);
    stopForIndex.add(t.index);
      .mapToInt(t -> indexForStop.get(t.index))
      .toArray();
for (TIntIntIterator trIt = transfersFromStop.iterator(); trIt.hasNext();) {
  trIt.advance();
  transfersFromStopWithGraphIndices.put(stopForIndex.get(trIt.key()), trIt.value());
for (TIntIntIterator it = transfersToStop.iterator(); it.hasNext(); ) {
  it.advance();
  temporaryTransfers.get(graphIndex).put(t.index, it.value());
    int targetStopIndex = indexForStop.get(simpleTransfer.getToVertex().getIndex());
    if (targetStopIndex != -1) {
      transfers.add(targetStopIndex);
  for (TIntIntIterator tranIt = temporaryTransfers.get(stop).iterator(); tranIt.hasNext();) {

代码示例来源:origin: shilad/wikibrain

@Override
public SRResultList mostSimilar(int pageId, int maxResults, TIntSet validIds) throws DaoException {
  TIntIntMap scores = new TIntIntHashMap();
  for (int id : getLinks(pageId, true)) {
    if (validIds == null || validIds.contains(id)) scores.adjustOrPutValue(id, 1, 1);
  }
  for (int id : getLinks(pageId, false)) {
    if (validIds == null || validIds.contains(id)) scores.adjustOrPutValue(id, 1, 1);
  }
  Leaderboard leaderboard = new Leaderboard(maxResults);
  for (int id : scores.keys()) {
    leaderboard.tallyScore(id, scores.get(id) / 2.0);
  }
  return normalize(leaderboard.getTop());
}

代码示例来源:origin: alibaba/mdrill

/** {@inheritDoc} */
public void putAll( TIntIntMap map ) {
  ensureCapacity( map.size() );
  TIntIntIterator iter = map.iterator();
  while ( iter.hasNext() ) {
    iter.advance();
    this.put( iter.key(), iter.value() );
  }
}

代码示例来源:origin: CalebFenton/simplify

@Override
public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) {
  SwitchPayload instr = (SwitchPayload) location.getInstruction();
  TIntIntMap targetKeyToOffset = new TIntIntHashMap();
  for (SwitchElement element : instr.getSwitchElements()) {
    targetKeyToOffset.put(element.getKey(), element.getOffset());
  }
  return new SwitchPayloadOp(location, addressToLocation, targetKeyToOffset);
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

TIntIntMap accessTimes = new TIntIntHashMap();
    int stopIndex = indexForStop.get(tstop.getIndex());
        accessTimes.put(stopIndex, (int) s.getElapsedTimeSeconds());
      else
        accessTimes.put(stopIndex, (int) (s.getWalkDistance() / walkSpeed));
  accessTimes.put(it.value(), (int) (dist / walkSpeed));

代码示例来源:origin: edu.ucla.sspace/sspace-wordsi

/**
 * {@inheritDoc}
 */
public void set(int index, int value) {
  int cur = map.get(index);
  if (value == 0) {
    if (cur != 0)
      map.remove(index);
  }
  else 
    map.put(index, value);
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

TIntIntMap initialStops = new TIntIntHashMap();
TIntIntIterator initialIterator = accessTimes.iterator();
while (initialIterator.hasNext()) {
  initialIterator.advance();
  int stopIndex = initialIterator.key();
  int accessTime = initialIterator.value();
  initialStops.put(stopIndex, accessTime);

代码示例来源:origin: SlimeKnights/TinkersConstruct

TIntIntMap assigned = new TIntIntHashMap();
TinkersItem tool = (TinkersItem) toolStack.getItem();
   if(!assigned.valueCollection().contains(j)) {
    candidate = j;
  return ItemStack.EMPTY;
 assigned.put(i, candidate);
if(assigned.isEmpty()) {
 return ItemStack.EMPTY;
assigned.forEachEntry((i, j) -> {
 String mat = ((IToolPart) toolParts.get(i).getItem()).getMaterial(toolParts.get(i)).getIdentifier();
 materialList.set(j, new NBTTagString(mat));

代码示例来源:origin: palantir/atlasdb

private synchronized void decrementReadCount(int clientIndex) {
  if (readLockHolders == null) {
    throw LockServerLock.throwIllegalMonitorStateException(
        clients.fromIndex(clientIndex) +
        " does not hold the read lock");
  }
  int readCount = readLockHolders.remove(clientIndex);
  if (readCount > 1) {
    readLockHolders.put(clientIndex, readCount - 1);
  } else if (readCount == 0) {
    throw LockServerLock.throwIllegalMonitorStateException(
        clients.fromIndex(clientIndex) +
        " does not hold the read lock");
  }
}

代码示例来源:origin: CalebFenton/simplify

@Override
public void execute(ExecutionNode node, MethodState mState) {
  // Pseudo points to instruction *after* switch op.
  MethodLocation returnLocation = mState.getPseudoInstructionReturnInstruction();
  int branchFromAddress = returnLocation.getCodeAddress() - SWITCH_OP_CODE_UNITS;
  HeapItem targetItem = mState.readResultRegister();
  if (targetItem.isUnknown()) {
    List<MethodLocation> childList = getTargets(branchFromAddress, targetKeyToOffset);
    childList.add(returnLocation);
    MethodLocation[] children = childList.toArray(new MethodLocation[childList.size()]);
    node.setChildLocations(children);
    return;
  }
  int targetKey = Utils.getIntegerValue(targetItem.getValue());
  if (targetKeyToOffset.containsKey(targetKey)) {
    int targetOffset = branchFromAddress + targetKeyToOffset.get(targetKey);
    MethodLocation child = addressToLocation.get(targetOffset);
    node.setChildLocations(child);
    return;
  }
  // Branch target is unspecified. Continue to next op.
  node.setChildLocations(returnLocation);
}

代码示例来源:origin: CyclopsMC/IntegratedDynamics

protected static int getGroupColor(int group) {
  if (!CACHED_GROUP_COLORS.containsKey(group)) {
    Random rand = new Random(group);
    int color = rand.nextInt(1 << 23) | (255 << 24);
    CACHED_GROUP_COLORS.put(group, color);
    return color;
  }
  return CACHED_GROUP_COLORS.get(group);
}

代码示例来源:origin: MovingBlocks/Terasology

private int getActiveShaderProgramId() {
  return disposalAction.shaderPrograms.get(activeFeaturesMask);
}

代码示例来源:origin: palantir/atlasdb

private synchronized void incrementReadCount(int clientIndex) {
  if (readLockHolders == null) {
    readLockHolders = new TIntIntHashMap(1);
  }
  readLockHolders.adjustOrPutValue(clientIndex, 1, 1);
}

代码示例来源:origin: MovingBlocks/Terasology

@Override
public void recompile() {
  TIntIntIterator it = disposalAction.shaderPrograms.iterator();
  while (it.hasNext()) {
    it.advance();
    GL20.glDeleteProgram(it.value());
  }
  disposalAction.shaderPrograms.clear();
  uniformLocationMap.clear();
  bindMap.clear();
  disposalAction.shaderPrograms.put(0, shader.linkShaderProgram(0));
  for (Set<ShaderProgramFeature> permutation : Sets.powerSet(shader.getAvailableFeatures())) {
    int featureMask = ShaderProgramFeature.getBitset(permutation);
    disposalAction.shaderPrograms.put(featureMask, shader.linkShaderProgram(featureMask));
  }
  //resolves #966
  //Some of the uniforms are not updated constantly between frames
  //this function will rebind any uniforms that are not bound
  rebindVariables(materialData);
}

代码示例来源:origin: alibaba/mdrill

/**
 * Retrieves the value for <tt>key</tt>
 *
 * @param key an <code>Object</code> value
 * @return the value of <tt>key</tt> or null if no such mapping exists.
 */
public Integer get( Object key ) {
  int k;
  if ( key != null ) {
    if ( key instanceof Integer ) {
      k = unwrapKey( key );
    } else {
      return null;
    }
  } else {
    k = _map.getNoEntryKey();
  }
  int v = _map.get( k );
  // There may be a false positive since primitive maps
  // cannot return null, so we have to do an extra
  // check here.
  if ( v == _map.getNoEntryValue() ) {
    return null;
  } else {
    return wrapValue( v );
  }
}

代码示例来源:origin: alibaba/mdrill

public int[] keys() {
  synchronized( mutex ) { return m.keys(); }
}
public int[] keys( int[] array ) {

相关文章