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

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

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

TreeMap.putAll介绍

[英]Copies all of the mappings from the specified map to this map. These mappings replace any mappings that this map had for any of the keys currently in the specified map.
[中]将指定映射中的所有映射复制到此映射。这些映射将替换此映射对指定映射中当前任何键所具有的任何映射。

代码示例

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

protected Map<K,V> copy() {
  TreeMap<K,V> m = new TreeMap<K,V>(comparator);
  m.putAll(core);
  return m;
}

代码示例来源:origin: goldmansachs/gs-collections

public void putAll(Map<? extends K, ? extends V> map)
{
  this.treeMap.putAll(map);
}

代码示例来源:origin: sannies/mp4parser

public void putAll(Map<? extends K, ? extends V> m) {
  base.putAll(m);
}

代码示例来源:origin: goldmansachs/gs-collections

public TreeSortedMap(Comparator<? super K> comparator, Map<? extends K, ? extends V> map)
{
  this.treeMap = new TreeMap<K, V>(comparator);
  this.treeMap.putAll(map);
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

public Map sort(final Class type, final Map nameMap) {
  TreeMap map = new TreeMap(comparator);
  map.putAll(nameMap);
  return map;
}

代码示例来源:origin: looly/hutool

/**
 * 排序Map
 * 
 * @param <K> 键类型
 * @param <V> 值类型
 * @param map Map
 * @param comparator Entry比较器
 * @return {@link TreeMap}
 * @since 3.0.9
 */
public static <K, V> TreeMap<K, V> sort(Map<K, V> map, Comparator<? super K> comparator) {
  final TreeMap<K, V> result = new TreeMap<K, V>(comparator);
  result.putAll(map);
  return result;
}

代码示例来源:origin: looly/hutool

/**
 * 排序Map
 * 
 * @param <K> 键类型
 * @param <V> 值类型
 * @param map Map
 * @param comparator Entry比较器
 * @return {@link TreeMap}
 * @since 3.0.9
 */
public static <K, V> TreeMap<K, V> sort(Map<K, V> map, Comparator<? super K> comparator) {
  final TreeMap<K, V> result = new TreeMap<K, V>(comparator);
  result.putAll(map);
  return result;
}

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

public void rollback() {
  try {
    this.lockTreeMap.writeLock().lockInterruptibly();
    try {
      this.msgTreeMap.putAll(this.consumingMsgOrderlyTreeMap);
      this.consumingMsgOrderlyTreeMap.clear();
    } finally {
      this.lockTreeMap.writeLock().unlock();
    }
  } catch (InterruptedException e) {
    log.error("rollback exception", e);
  }
}

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

@JsonIgnore
public TreeMap<String, NamespaceBundleStats> getSortedBundleStats(ResourceType resType) {
  if (bundleStats == null) {
    return null;
  }
  NamespaceBundleStatsComparator nsc = new NamespaceBundleStatsComparator(bundleStats, resType);
  TreeMap<String, NamespaceBundleStats> sortedBundleStats = Maps.newTreeMap(nsc);
  sortedBundleStats.putAll(bundleStats);
  return sortedBundleStats;
}

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

sorted_map.putAll(map);
System.out.println("results: " + sorted_map);

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

/**
 * Returns a map of all the flattened properties, the item in the returned map is sorted
 * alphabetically by the key value.
 *
 * @Return
 */
public Map<String, String> getFlattened() {
 final TreeMap<String, String> returnVal = new TreeMap<>();
 returnVal.putAll(getMapByPrefix(""));
 return returnVal;
}

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

@Override
  public DatabaseBranches clone() {
    DatabaseBranches clonedBranches = new DatabaseBranches();
    clonedBranches.branches.putAll(branches);
    
    return clonedBranches;
  }
}

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

/**
 * Clones the file history, including its file versions. Note that file versions
 * are not cloned, but copied by reference.
 *
 * @return Returns cloned file history
 */
@Override
public PartialFileHistory clone() {
  PartialFileHistory clone = new PartialFileHistory(fileHistoryId);
  clone.versions.putAll(versions);
  return clone;
}

代码示例来源:origin: looly/hutool

/**
 * 新建TreeMap,Key有序的Map
 * 
 * @param map Map
 * @param comparator Key比较器
 * @return TreeMap
 * @since 3.2.3
 */
public static <K, V> TreeMap<K, V> newTreeMap(Map<K, V> map, Comparator<? super K> comparator) {
  final TreeMap<K, V> treeMap = new TreeMap<>(comparator);
  if (false == isEmpty(map)) {
    treeMap.putAll(map);
  }
  return treeMap;
}

代码示例来源:origin: looly/hutool

/**
 * 新建TreeMap,Key有序的Map
 * 
 * @param map Map
 * @param comparator Key比较器
 * @return TreeMap
 * @since 3.2.3
 */
public static <K, V> TreeMap<K, V> newTreeMap(Map<K, V> map, Comparator<? super K> comparator) {
  final TreeMap<K, V> treeMap = new TreeMap<>(comparator);
  if (false == isEmpty(map)) {
    treeMap.putAll(map);
  }
  return treeMap;
}

代码示例来源:origin: igniterealtime/Smack

@Override
public TreeMap<Integer, T_SigPreKey> loadOmemoSignedPreKeys(OmemoDevice userDevice) {
  TreeMap<Integer, T_SigPreKey> sigPreKeys = getCache(userDevice).signedPreKeys;
  if (sigPreKeys.isEmpty() && persistent != null) {
    sigPreKeys.putAll(persistent.loadOmemoSignedPreKeys(userDevice));
  }
  return new TreeMap<>(sigPreKeys);
}

代码示例来源:origin: igniterealtime/Smack

@Override
public TreeMap<Integer, T_PreKey> loadOmemoPreKeys(OmemoDevice userDevice) {
  TreeMap<Integer, T_PreKey> preKeys = getCache(userDevice).preKeys;
  if (preKeys.isEmpty() && persistent != null) {
    preKeys.putAll(persistent.loadOmemoPreKeys(userDevice));
  }
  return new TreeMap<>(preKeys);
}

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

ReadableTransactionState build()
  {
    final ReadableTransactionState mock = Mockito.mock( ReadableTransactionState.class );
    doReturn( new UnmodifiableMap<>( updates ) ).when( mock ).getIndexUpdates( any( SchemaDescriptor.class ) );
    final TreeMap<ValueTuple, MutableLongDiffSetsImpl> sortedMap = new TreeMap<>( ValueTuple.COMPARATOR );
    sortedMap.putAll( updates );
    doReturn( sortedMap ).when( mock ).getSortedIndexUpdates( any( SchemaDescriptor.class ) );
    return mock;
  }
}

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

@SuppressWarnings("unchecked")
  private Map<String, Object> asMap(String json) throws java.io.IOException {
    final TreeMap<String, Object> result = new TreeMap<String, Object>();
    result.putAll(JsonUtils.getMapper().readValue(json, Map.class));
    return result;
  }
}

相关文章

微信公众号

最新文章

更多