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

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

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

TreeMap.remove介绍

[英]Removes the mapping for this key from this TreeMap if present.
[中]从此树映射中删除此键的映射(如果存在)。

代码示例

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

private static void setPrincipalPermission(TreeMap principalPermissions, String principal, int perm) {
  if (perm == 0)
    principalPermissions.remove(principal);
  else
    principalPermissions.put(principal, new Integer(perm));
}

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

private static boolean removeFromRunningTaskMap(TreeMap<Integer, TreeSet<TaskInfo>> runningTasks,
  Object task, TaskInfo taskInfo) {
 int priority = taskInfo.priority.getPriority();
 Set<TaskInfo> tasksAtPriority = runningTasks.get(priority);
 if (tasksAtPriority == null) return false;
 boolean result = tasksAtPriority.remove(taskInfo);
 if (tasksAtPriority.isEmpty()) {
  runningTasks.remove(priority);
 }
 return result;
}

代码示例来源:origin: stackoverflow.com

if (valueMap.containsKey(k)){
  remove(k);
map.put("a", 5);
map.put("b", 1);
map.put("c", 3);
assertEquals("b",map.firstKey());
assertEquals("a",map.lastKey());
map.put("e", 2);
assertEquals(5, map.size());
assertEquals(2, (int) map.get("e"));
assertEquals(2, (int) map.get("d"));

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

this.shortLengths.put(i, edge);
} else {
  this.lengths.put(i, edge);
  this.lengths.remove(e.getId());
} else  {
  Edge e0 = triangle.getEdges().get(0);
      && e1.getOV().isBorder() && e1.getEV().isBorder()) {
    this.shortLengths.put(e.getId(), e);
    this.lengths.remove(e.getId());
  } else {
        this.lengths.put(eC.getId(), eC);
      this.lengths.remove(eA.getId());
    } else if (eB.isBorder()) {
      this.edges.remove(eB.getId());
        this.lengths.put(eC.getId(), eC);
      this.lengths.remove(eB.getId());
    } else {
      this.edges.remove(eC.getId());
        this.lengths.put(eB.getId(), eB);
      this.lengths.remove(eC.getId());

代码示例来源:origin: prestodb/presto

if (name.split("\\.").length == size && name.startsWith(prefix)) {
    Optional<String> columnName = Optional.of(name.substring(name.lastIndexOf('.') + 1));
    Type columnType = fieldsMap.get(name);
    Field column = new Field(columnName, columnType);
    fieldsBuilder.add(column);
fieldsMap.put(prefix, RowType.from(fieldsBuilder.build()));
  columns.add(new ElasticsearchColumn(field, type, field, type.getDisplayName(), arrays.contains(field), -1));
fieldsMap.remove(field);

代码示例来源:origin: kevin-wayne/algs4

/**
 * Inserts the specified key-value pair into the symbol table, overwriting the old 
 * value with the new value if the symbol table already contains the specified key.
 * Deletes the specified key (and its associated value) from this symbol table
 * if the specified value is {@code null}.
 *
 * @param  key the key
 * @param  val the value
 * @throws IllegalArgumentException if {@code key} is {@code null}
 */
public void put(Key key, Value val) {
  if (key == null) throw new IllegalArgumentException("calls put() with null key");
  if (val == null) st.remove(key);
  else             st.put(key, val);
}

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

private void deleteSortMap(int a, int b, double oridata) {
  Set<String> set = sortmap.get(oridata);
  if (set == null)
    return;
  if (set.size() == 1)
    sortmap.remove(oridata);
  else
    set.remove(id2String(a, b));
}

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

return false;
  tmpSize -= this.workUnitsMap.get(existingFileSet).size();
  partitionsToDelete.add(existingFileSet);
  if (tmpSize + workUnits.size() <= this.strictMaxSize) {
  List<WorkUnit> workUnitsRemoved = this.workUnitsMap.remove(fileSetToRemove);
  this.currentSize -= workUnitsRemoved.size();
 this.workUnitsMap.put(fileSet, workUnits);
} else {
 this.workUnitsMap.get(fileSet).addAll(workUnits);

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

/** */
private synchronized void onQueryDone(UUID nodeId, Long ver) {
  TreeMap<Long, AtomicInteger> nodeMap = activeQueries.get(nodeId);
  if (nodeMap == null)
    return;
  assert minQry != null;
  AtomicInteger cntr = nodeMap.get(ver);
  assert cntr != null && cntr.get() > 0 : "onQueryDone ver=" + ver;
  if (cntr.decrementAndGet() == 0) {
    nodeMap.remove(ver);
    if (nodeMap.isEmpty())
      activeQueries.remove(nodeId);
    if (ver.equals(minQry))
      minQry = activeMinimal();
  }
}

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

ImmutablePair<String, Object> groupKeyResultPair = new ImmutablePair<>(groupKey, result);
List<ImmutablePair<String, Object>> groupKeyResultPairs = _treeMap.get(newKey);
if (_numValuesAdded >= _trimSize) {
   _treeMap.put(newKey, groupKeyResultPairs);
   _treeMap.remove(maxKey);
  _treeMap.put(newKey, groupKeyResultPairs);

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

public void makeMessageToCosumeAgain(List<MessageExt> msgs) {
  try {
    this.lockTreeMap.writeLock().lockInterruptibly();
    try {
      for (MessageExt msg : msgs) {
        this.consumingMsgOrderlyTreeMap.remove(msg.getQueueOffset());
        this.msgTreeMap.put(msg.getQueueOffset(), msg);
      }
    } finally {
      this.lockTreeMap.writeLock().unlock();
    }
  } catch (InterruptedException e) {
    log.error("makeMessageToCosumeAgain exception", e);
  }
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * Remove a relationship by its ID.
 *
 * @param id
 *            The relationship ID to remove.
 */
public void removeRelationship(String id) {
  PackageRelationship rel = relationshipsByID.get(id);
  if (rel != null) {
    relationshipsByID.remove(rel.getId());
    relationshipsByType.values().remove(rel);
    internalRelationshipsByTargetName.values().remove(rel);
  }
}

代码示例来源:origin: h2oai/h2o-2

assert(prob >= 0 && prob <= 1) : "prob is not inside [0,1]: " + prob;
if (prob_idx.containsKey(prob)) {
 prob_idx.get(prob).add(label); //add all ties
} else {
  List<Integer> li = new LinkedList<Integer>();
  li.add(label);
  prob_idx.put(prob, li);
  prob_idx.remove(prob_idx.lastKey());
prob_idx.remove(prob);

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

LOG.debug("supervisorsWithFailures : {}", supervisorsWithFailures);
    reporter.reportBlacklist(supervisor, supervisorsWithFailures);
    blacklist.put(supervisor, resumeTime / nimbusMonitorFreqSecs);
LOG.debug("Releasing {} nodes because of low resources", toRelease.size());
for (String key: toRelease) {
  blacklist.remove(key);

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

void remove(int key, int value) {
  GHIntHashSet set = map.get(value);
  if (set == null || !set.remove(key)) {
    throw new IllegalStateException("cannot remove key " + key + " with value " + value
        + " - did you insert " + key + "," + value + " before?");
  }
  size--;
  if (set.isEmpty()) {
    map.remove(value);
  }
}

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

List<FileStatus> entitiesForTimestamp = orderedEntries.get(status.getModificationTime());
if (entitiesForTimestamp == null) {
  entitiesForTimestamp = new ArrayList<FileStatus>();
  orderedEntries.put(status.getModificationTime(), entitiesForTimestamp);
orderedEntries.remove(latestListingTimestamp);

代码示例来源:origin: com.h2database/h2

@Override
public void moveTo(FilePath newName, boolean atomicReplace) {
  synchronized (MEMORY_FILES) {
    if (!atomicReplace && !name.equals(newName.name) &&
        MEMORY_FILES.containsKey(newName.name)) {
      throw DbException.get(ErrorCode.FILE_RENAME_FAILED_2, name, newName + " (exists)");
    }
    FileNioMemData f = getMemoryFile();
    f.setName(newName.name);
    MEMORY_FILES.remove(name);
    MEMORY_FILES.put(newName.name, f);
  }
}

代码示例来源:origin: org.apache.poi/poi-ooxml

private void flushOneRow() throws IOException
{
  Integer firstRowNum = _rows.firstKey();
  if (firstRowNum!=null) {
    int rowIndex = firstRowNum.intValue();
    SXSSFRow row = _rows.get(firstRowNum);
    // Update the best fit column widths for auto-sizing just before the rows are flushed
    _autoSizeColumnTracker.updateColumnWidths(row);
    _writer.writeRow(rowIndex, row);
    _rows.remove(firstRowNum);
    lastFlushedRowNumber = rowIndex;
  }
}
public void changeRowNum(SXSSFRow row, int newRowNum)

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

if (matchOld.match(bug)) {
    LinkedList<BugInstance> q = set.get(bug);
    if (q == null) {
      q = new LinkedList<>();
      set.put(bug, q);
if (!mapFromNewToOldBug.containsKey(bug)) {
  LinkedList<BugInstance> q = set.get(bug);
  if (q == null) {
    continue;
    i.remove();
    if (q.isEmpty()) {
      set.remove(bug);

相关文章