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

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

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

TreeMap.entrySet介绍

[英]Fields initialized to contain an instance of the entry set view the first time this view is requested. Views are stateless, so there's no reason to create more than one.
[中]第一次请求该视图时,初始化为包含条目集视图实例的字段。视图是无状态的,因此没有理由创建多个视图。

代码示例

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

/**
 * 本状态的目标状态们的入度减一
 * Decrements (by 1) the incoming _transition counts of all of the nodes
 * that are targets of outgoing transitions from this node.
 */
public void decrementTargetIncomingTransitionCounts()
{
  for(Entry<Character, MDAGNode> transitionKeyValuePair: outgoingTransitionTreeMap.entrySet())
    transitionKeyValuePair.getValue().incomingTransitionCount--;
}

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

static void combineReverseChain(TreeMap<String, String> t2s, TreeMap<String, String> tw2t, boolean convert)
{
  for (Map.Entry<String, String> entry : tw2t.entrySet())
  {
    String tw = entry.getKey();
    String s = t2s.get(entry.getValue());
    if (s == null)
      s = convert ? CharTable.convert(entry.getValue()) : entry.getValue();
    t2s.put(tw, s);
  }
}

代码示例来源:origin: google/ExoPlayer

private void removePreviouslyExpiredManifestPublishTimeValues() {
 for (Iterator<Map.Entry<Long, Long>> it =
     manifestPublishTimeToExpiryTimeUs.entrySet().iterator();
   it.hasNext(); ) {
  Map.Entry<Long, Long> entry = it.next();
  long expiredManifestPublishTime = entry.getKey();
  if (expiredManifestPublishTime < manifest.publishTimeMs) {
   it.remove();
  }
 }
}

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

@Override
public long getNextScheduleTime() throws Exception {
  long nextExecutionTime = -1L;
  lock.readLock().lock();
  try {
    if (!jobs.isEmpty()) {
      nextExecutionTime = jobs.entrySet().iterator().next().getKey();
    }
  } finally {
    lock.readLock().unlock();
  }
  return nextExecutionTime;
}

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

private int distributeGuaranteed(int count, TaskInfo failedUpdate, List<TaskInfo> toUpdate) {
 WM_LOG.info("Distributing " + count + " among " + speculativeTasks.size() + " levels"
   + (failedUpdate == null ? "" : "; on failure"));
 Iterator<Entry<Integer, TreeSet<TaskInfo>>> iterator = speculativeTasks.entrySet().iterator();
 int remainingCount = count;
 // When done, handleUpdate.. may break the iterator, so the order of these checks is important.
 while (remainingCount > 0 && iterator.hasNext()) {
  remainingCount = handleUpdateForSinglePriorityLevel(
    remainingCount, iterator, failedUpdate, toUpdate, true);
 }
 return count - remainingCount;
}

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

featureFunctionList.put(b, null);
  char[] charArray = args[1].toCharArray();
  FeatureFunction featureFunction = new FeatureFunction(charArray, sizeOfTagSet);
  featureFunctionMap.put(args[1], featureFunction);
  featureFunctionList.put(Integer.parseInt(args[0]), featureFunction);
for (Map.Entry<Integer, FeatureFunction> entry : featureFunctionList.entrySet())
  int fid = entry.getKey();
  FeatureFunction featureFunction = entry.getValue();
  if (fid == b)
for (Map.Entry<Integer, FeatureFunction> entry : featureFunctionList.entrySet())
  int id = entry.getKey();
  FeatureFunction f = entry.getValue();
  if (f == null) continue;
  String feature = new String(f.o);
    String header = iterator.next();
    if (feature.startsWith(header))

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * The method normalizes the weights and bone indexes data.
 * First it truncates the amount to MAXIMUM_WEIGHTS_PER_VERTEX because this is how many weights JME can handle.
 * Next it normalizes the weights so that the sum of all verts is 1.
 * @param maximumSize
 *            the maximum size that the data will be truncated to (usually: MAXIMUM_WEIGHTS_PER_VERTEX)
 */
private void normalizeBoneBuffers(int maximumSize) {
  for (TreeMap<Float, Integer> group : boneWeightAndIndexes) {
    if (group.size() > maximumSize) {
      NavigableMap<Float, Integer> descendingWeights = group.descendingMap();
      while (descendingWeights.size() > maximumSize) {
        descendingWeights.pollLastEntry();
      }
    }
    // normalizing the weights so that the sum of the values is equal to '1'
    TreeMap<Float, Integer> normalizedGroup = new TreeMap<Float, Integer>();
    float sum = 0;
    for (Entry<Float, Integer> entry : group.entrySet()) {
      sum += entry.getKey();
    }
    if (sum != 0 && sum != 1) {
      for (Entry<Float, Integer> entry : group.entrySet()) {
        normalizedGroup.put(entry.getKey() / sum, entry.getValue());
      }
      group.clear();
      group.putAll(normalizedGroup);
    }
  }
}

代码示例来源:origin: org.osgi/org.osgi.compendium

private static void deleteFromAll(TreeMap principalPermissions, int perm) {
  Iterator i = principalPermissions.entrySet().iterator();
  while (i.hasNext()) {
    Map.Entry entry = (Map.Entry) i.next();
    setPrincipalPermission(principalPermissions, (String) entry.getKey(), ((Integer) entry.getValue()).intValue() & ~perm);
  }
}

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

@Override
public List<Job> getNextScheduleJobs() throws Exception {
  List<Job> result = new ArrayList<>();
  lock.readLock().lock();
  try {
    if (!jobs.isEmpty()) {
      result.addAll(jobs.entrySet().iterator().next().getValue().getAllJobs());
    }
  } finally {
    lock.readLock().unlock();
  }
  return result;
}

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

@Override
public void merge(Accumulator<Integer, TreeMap<Integer, Integer>> other) {
  // Merge the values into this map
  for (Map.Entry<Integer, Integer> entryFromOther : other.getLocalValue().entrySet()) {
    Integer ownValue = this.treeMap.get(entryFromOther.getKey());
    if (ownValue == null) {
      this.treeMap.put(entryFromOther.getKey(), entryFromOther.getValue());
    } else {
      this.treeMap.put(entryFromOther.getKey(), entryFromOther.getValue() + ownValue);
    }
  }
}

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

/**
 * 克隆一个状态<br>
 * Constructs an MDAGNode possessing the same accept state status and outgoing transitions as another.
 
 * @param node      the MDAGNode possessing the accept state status and 
 *                  outgoing transitions that the to-be-created MDAGNode is to take on
 */
private MDAGNode(MDAGNode node)
{
  isAcceptNode = node.isAcceptNode;
  outgoingTransitionTreeMap = new TreeMap<Character, MDAGNode>(node.outgoingTransitionTreeMap);
  
  //Loop through the nodes in this node's outgoing _transition set, incrementing the number of
  //incoming transitions of each by 1 (to account for this newly created node's outgoing transitions)
  for(Entry<Character, MDAGNode> transitionKeyValuePair : outgoingTransitionTreeMap.entrySet())
    transitionKeyValuePair.getValue().incomingTransitionCount++;
  /////
}

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

public void printBrokerRuntimeStats(final DefaultMQAdminExt defaultMQAdminExt, final String brokerAddr,
    final boolean printBroker) throws InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
    KVTable kvTable = defaultMQAdminExt.fetchBrokerRuntimeStats(brokerAddr);

    TreeMap<String, String> tmp = new TreeMap<String, String>();
    tmp.putAll(kvTable.getTable());

    Iterator<Entry<String, String>> it = tmp.entrySet().iterator();
    while (it.hasNext()) {
      Entry<String, String> next = it.next();
      if (printBroker) {
        System.out.printf("%-24s %-32s: %s%n", brokerAddr, next.getKey(), next.getValue());
      } else {
        System.out.printf("%-32s: %s%n", next.getKey(), next.getValue());
      }
    }
  }
}

代码示例来源: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: hankcs/HanLP

public int build(TreeMap<String, Integer> keyValueMap)
{
  idToLabelMap = new String[keyValueMap.size()];
  for (Map.Entry<String, Integer> entry : keyValueMap.entrySet())
  {
    idToLabelMap[entry.getValue()] = entry.getKey();
  }
  return trie.build(keyValueMap);
}

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

public void setKeepDeletes(boolean keepDeletes) {
 this.keepDeletes = keepDeletes;
 // If not to keep deletes, remove the BitSetNodes which are empty (i.e. contains ids of deleted
 // procedures).
 if (!keepDeletes) {
  Iterator<Map.Entry<Long, BitSetNode>> it = map.entrySet().iterator();
  while (it.hasNext()) {
   Map.Entry<Long, BitSetNode> entry = it.next();
   if (entry.getValue().isEmpty()) {
    it.remove();
   }
  }
 }
}

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

/**
 * 将分数map排序折叠
 * @param scoreMap
 * @return
 */
private static TreeMap<Double ,Set<String>> sortScoreMap(TreeMap<String, Double> scoreMap)
{
  TreeMap<Double, Set<String>> result = new TreeMap<Double, Set<String>>(Collections.reverseOrder());
  for (Map.Entry<String, Double> entry : scoreMap.entrySet())
  {
    Set<String> sentenceSet = result.get(entry.getValue());
    if (sentenceSet == null)
    {
      sentenceSet = new HashSet<String>();
      result.put(entry.getValue(), sentenceSet);
    }
    sentenceSet.add(entry.getKey());
  }
  return result;
}

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

@Override
public int build(TreeMap<String, V> keyValueMap)
{
  for (Map.Entry<String, V> entry : keyValueMap.entrySet())
  {
    put(entry.getKey(), entry.getValue());
  }
  return 0;
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
 public String toString() {
  StringBuilder sb = new StringBuilder();
  sb.append("size: ").append(this.theMetadata.size()).append("\n");
  Iterator<Map.Entry<Text, Text>> iter =
   this.theMetadata.entrySet().iterator();
  while (iter.hasNext()) {
   Map.Entry<Text, Text> en = iter.next();
   sb.append("\t").append(en.getKey().toString()).append("\t").append(en.getValue().toString());
   sb.append("\n");
  }
  return sb.toString();
 }
}

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

@Override
public void resumeFromBlacklist() {
  Set<String> readyToRemove = new HashSet<>();
  for (Map.Entry<String, Integer> entry : blacklist.entrySet()) {
    String key = entry.getKey();
    int value = entry.getValue() - 1;
    if (value == 0) {
      readyToRemove.add(key);
    } else {
      blacklist.put(key, value);
    }
  }
  for (String key : readyToRemove) {
    blacklist.remove(key);
    LOG.info("Supervisor {} has been blacklisted more than resume period. Removed from blacklist.", key);
  }
}

代码示例来源:origin: apache/incubator-dubbo

public static String toQueryString(Map<String, String> ps) {
  StringBuilder buf = new StringBuilder();
  if (ps != null && ps.size() > 0) {
    for (Map.Entry<String, String> entry : new TreeMap<String, String>(ps).entrySet()) {
      String key = entry.getKey();
      String value = entry.getValue();
      if (isNoneEmpty(key, value)) {
        if (buf.length() > 0) {
          buf.append("&");
        }
        buf.append(key);
        buf.append("=");
        buf.append(value);
      }
    }
  }
  return buf.toString();
}

相关文章