java.util.TreeMap.containsKey()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(176)

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

TreeMap.containsKey介绍

[英]Returns true if this map contains a mapping for the specified key.
[中]如果此映射包含指定键的映射,则返回true。

代码示例

代码示例来源:origin: hankcs/HanLP

private Nature(String name)
{
  if (idMap == null) idMap = new TreeMap<String, Integer>();
  assert !idMap.containsKey(name);
  this.name = name;
  ordinal = idMap.size();
  idMap.put(name, ordinal);
  Nature[] extended = new Nature[idMap.size()];
  if (values != null)
    System.arraycopy(values, 0, extended, 0, values.length);
  extended[ordinal] = this;
  values = extended;
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Splits the range set at the given timestamp (if it hasn't been split yet)
 */
private void splitAt(long t) {
  if (data.containsKey(t)) return; // already split at this timestamp
  SortedMap<Long, int[]> head = data.headMap(t);
  int v = head.isEmpty() ? 0 : data.get(head.lastKey())[0];
  data.put(t, new int[]{v});
}

代码示例来源:origin: apache/storm

/**
 * Returns null if it was created, the value otherwise.
 */
public Object getStateOrCreate(long txid, StateInitializer init) {
  Object state;
  if (_curr.containsKey(txid)) {
    state = _curr.get(txid);
  } else {
    getState(txid, init);
    state = null;
  }
  return state;
}

代码示例来源:origin: apache/accumulo

defaults.put(defaultEntry.getKey(), defaultEntry.getValue());
for (Entry<String,String> e : shellState.getAccumuloClient().namespaceOperations()
  .getProperties(n)) {
 namespaceConfig.put(e.getKey(), e.getValue());
sortedConf.put(propEntry.getKey(), propEntry.getValue());
 continue;
 if (defaults.containsKey(key) && !Property.getPropertyByKey(key).isExperimental()) {
  printConfLine(output, "default", key, dfault);
  printed = true;
 if (!defaults.containsKey(key) || !defaults.get(key).equals(siteVal)) {
  printConfLine(output, "site", printed ? "   @override" : key,
    siteVal == null ? "" : siteVal);
  printed = true;
 if (!siteConfig.containsKey(key) || !siteVal.equals(sysVal)) {
  printConfLine(output, "system", printed ? "   @override" : key, sysVal);
  printed = true;
 if (!systemConfig.containsKey(key) || !sysVal.equals(nspVal)) {
  printConfLine(output, "namespace", printed ? "   @override" : key, nspVal);
  printed = true;

代码示例来源:origin: hankcs/HanLP

static void combineChain(TreeMap<String, String> s2t, TreeMap<String, String> t2x)
{
  for (Map.Entry<String, String> entry : s2t.entrySet())
  {
    String x = t2x.get(entry.getValue());
    if (x != null)
    {
      entry.setValue(x);
    }
  }
  for (Map.Entry<String, String> entry : t2x.entrySet())
  {
    String s = CharTable.convert(entry.getKey());
    if (!s2t.containsKey(s))
    {
      s2t.put(s, entry.getValue());
    }
  }
}

代码示例来源:origin: robolectric/robolectric

synchronized private void changeDisplay(int displayId, DisplayInfo displayInfo) {
 if (!displayInfos.containsKey(displayId)) {
  throw new IllegalStateException("no display " + displayId);
 }
 displayInfos.put(displayId, displayInfo);
 notifyListeners(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED);
}

代码示例来源:origin: Alluxio/alluxio

/**
 * @param timeNano the time in nano seconds
 * @return the number of event happened in the bucket that includes timeNano
 */
public int get(long timeNano) {
 long leftEndPoint = bucket(timeNano);
 return mSeries.containsKey(leftEndPoint) ? mSeries.get(leftEndPoint) : 0;
}

代码示例来源:origin: Alluxio/alluxio

/**
 * Record events at a timestamp into the time series.
 * @param timeNano the time in nano seconds
 * @param numEvents the number of events happened at timeNano
 */
public void record(long timeNano, int numEvents) {
 long leftEndPoint = bucket(timeNano);
 mSeries.put(leftEndPoint,
   (mSeries.containsKey(leftEndPoint) ? mSeries.get(leftEndPoint) : 0) + numEvents);
}

代码示例来源:origin: apache/flink

@SuppressWarnings("unused")
protected static void checkAndCoSort(int[] positions, Class<?>[] types) {
  if (positions.length != types.length) {
    throw new IllegalArgumentException("The positions and types must be of the same length");
  }
  TreeMap<Integer, Class<?>> map = new TreeMap<Integer, Class<?>>();
  for (int i = 0; i < positions.length; i++) {
    if (positions[i] < 0) {
      throw new IllegalArgumentException("The field " + " (" + positions[i] + ") is invalid.");
    }
    if (types[i] == null) {
      throw new IllegalArgumentException("The type " + i + " is invalid (null)");
    }
    if (map.containsKey(positions[i])) {
      throw new IllegalArgumentException("The position " + positions[i] + " occurs multiple times.");
    }
    map.put(positions[i], types[i]);
  }
  int i = 0;
  for (Map.Entry<Integer, Class<?>> entry : map.entrySet()) {
    positions[i] = entry.getKey();
    types[i] = entry.getValue();
    i++;
  }
}

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

/**
 * Returns null if it was created, the value otherwise.
 */
public Object getStateOrCreate(BigInteger txid, StateInitializer init) {
  if (_curr.containsKey(txid)) {
    return _curr.get(txid);
  } else {
    getState(txid, init);
    return null;
  }
}

代码示例来源:origin: FudanNLP/fnlp

/**
 * 增加词+词性
 * @param pos
 * @param s
 */
private void add(String pos, String s) {
  if(s.length()>maxLen)
    return;
  if(pos.length()==0)
    return;
  posSet.add(pos);
  if(dict.containsKey(s)){
    TreeSet<String> sett = dict.get(s);
    sett.add(pos);
  }else{
    TreeSet<String> sett  = new TreeSet<String>();
    sett.add(pos);
    dict.put(s, sett);
  }
}

代码示例来源:origin: ankidroid/Anki-Android

public void register(Iterable<String> tags, Integer usn) {
  //boolean found = false;
  for (String t : tags) {
    if (!mTags.containsKey(t)) {
      mTags.put(t, usn == null ? mCol.usn() : usn);
      mChanged = true;
    }
  }
  //if (found) {
  //    runHook("newTag"); // TODO
  //}
}

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

/**
 * Returns null if it was created, the value otherwise.
 */
public Object getStateOrCreate(long txid, StateInitializer init) {
  if(_curr.containsKey(txid)) {
    return _curr.get(txid);
  } else {
    getState(txid, init);
    return null;
  }
}

代码示例来源:origin: FudanNLP/fnlp

private void addSortMap(int a, int b, double updatedata) {
  if (sortmap.containsKey(updatedata)) {
    Set<String> set = sortmap.get(updatedata);
    set.add(id2String(a, b));
  }
  else {
    Set<String> set = new HashSet<String>();
    set.add(id2String(a, b));
    sortmap.put(updatedata, set);
  }
}

代码示例来源:origin: apache/hive

public static void setColumnStatsState(Map<String, String> params, List<String> colNames) {
 if (params == null) {
  throw new RuntimeException("params are null...cant set columnstatstate!");
 }
 if (colNames == null) {
  return;
 }
 ColumnStatsAccurate stats = parseStatsAcc(params.get(COLUMN_STATS_ACCURATE));
 for (String colName : colNames) {
  if (!stats.columnStats.containsKey(colName)) {
   stats.columnStats.put(colName, true);
  }
 }
 try {
  params.put(COLUMN_STATS_ACCURATE, ColumnStatsAccurate.objectWriter.writeValueAsString(stats));
 } catch (JsonProcessingException e) {
  LOG.trace(e.getMessage());
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

@Override
public FileStream getStream( String filename ) {
 if ( fileNameMap.containsKey( filename ) ) {
  return fileNameMap.get( filename ).getFileStream();
 } else {
  return null;
 }
}

代码示例来源:origin: FudanNLP/fnlp

private void initSortMap() {
    for (int i = 0; i < feasize - 1; i++) {
      for (int j = i + 1; j < feasize; j++) {
        double temp = getDistance(i, j);
        Set<String> hashset;
        if (sortmap.containsKey(temp))
          hashset = sortmap.get(temp);
        else
          hashset = new HashSet<String>();
//                System.out.println(temp + " " + i + " " + j);
//                System.out.println(getDistance(i, j));
        hashset.add(id2String(i, j));
        sortmap.put(temp, hashset);
      }
    }
    System.out.println("Map init size: " + sortmap.size());
  }

代码示例来源:origin: apache/kafka

apiKeysText.put(supportedVersion.apiKey, apiVersionToText(supportedVersion));
for (ApiVersion apiVersion : unknownApis)
  apiKeysText.put(apiVersion.apiKey, apiVersionToText(apiVersion));
  if (!apiKeysText.containsKey(apiKey.id)) {
    StringBuilder bld = new StringBuilder();
    bld.append(apiKey.name).append("(").
        append(apiKey.id).append("): ").append("UNSUPPORTED");
    apiKeysText.put(apiKey.id, bld.toString());

代码示例来源:origin: hankcs/HanLP

MDAGNode currentTargetNode = transitionKeyValuePair.getValue();
if(!outgoingTransitionTreeMap2.containsKey(currentCharKey) || !outgoingTransitionTreeMap2.get(currentCharKey).equals(currentTargetNode))
  return false;

代码示例来源:origin: apache/hbase

private void addStartEndKeysForTest(TreeMap<byte[], Integer> map, byte[] first, byte[] last) {
 Integer value = map.containsKey(first) ? map.get(first) : 0;
 map.put(first, value + 1);
 value = map.containsKey(last) ? map.get(last) : 0;
 map.put(last, value - 1);
}

相关文章

微信公众号

最新文章

更多