本文整理了Java中java.util.HashMap.merge()
方法的一些代码示例,展示了HashMap.merge()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HashMap.merge()
方法的具体详情如下:
包路径:java.util.HashMap
类名称:HashMap
方法名:merge
暂无
代码示例来源:origin: apache/storm
private HashMap<NodeInfo, Stream<TaskMessage>> groupBundleByDestination(Map<Integer, NodeInfo> taskToNode) {
HashMap<NodeInfo, Stream<TaskMessage>> result = new HashMap<>();
for (Entry<Integer, ArrayList<TaskMessage>> entry : bundles.entrySet()) {
if (entry.getValue().isEmpty()) {
continue;
}
NodeInfo node = taskToNode.get(entry.getKey());
if (node != null) {
result.merge(node, entry.getValue().stream(), Stream::concat);
} else {
LOG.warn("No remote destination available for task {}", entry.getKey());
}
}
return result;
}
代码示例来源:origin: com.typesafe.play/play
/**
* @deprecated Deprecated as of 2.7.0. {@link Flash} will not be a subclass of {@link HashMap} in future Play releases.
*/
@Deprecated
@Override
public String merge(String key, String value, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
return super.merge(key, value, remappingFunction);
}
代码示例来源:origin: com.typesafe.play/play_2.12
/**
* @deprecated Deprecated as of 2.7.0. {@link Session} will not be a subclass of {@link HashMap} in future Play releases.
*/
@Deprecated
@Override
public String merge(String key, String value, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
return super.merge(key, value, remappingFunction);
}
代码示例来源:origin: com.typesafe.play/play_2.11
/**
* @deprecated Deprecated as of 2.7.0. {@link Session} will not be a subclass of {@link HashMap} in future Play releases.
*/
@Deprecated
@Override
public String merge(String key, String value, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
return super.merge(key, value, remappingFunction);
}
代码示例来源:origin: com.typesafe.play/play_2.12
/**
* @deprecated Deprecated as of 2.7.0. {@link Flash} will not be a subclass of {@link HashMap} in future Play releases.
*/
@Deprecated
@Override
public String merge(String key, String value, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
return super.merge(key, value, remappingFunction);
}
代码示例来源:origin: com.typesafe.play/play_2.11
/**
* @deprecated Deprecated as of 2.7.0. {@link Flash} will not be a subclass of {@link HashMap} in future Play releases.
*/
@Deprecated
@Override
public String merge(String key, String value, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
return super.merge(key, value, remappingFunction);
}
代码示例来源:origin: com.typesafe.play/play
/**
* @deprecated Deprecated as of 2.7.0. {@link Session} will not be a subclass of {@link HashMap} in future Play releases.
*/
@Deprecated
@Override
public String merge(String key, String value, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
return super.merge(key, value, remappingFunction);
}
代码示例来源:origin: de.mhus.lib/mhu-lib-core
@Override
public String merge(String key, String value,
BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
return map.merge(key, value, remappingFunction);
}
代码示例来源:origin: de.mhus.lib/mhu-lib-core
@Override public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
return map.merge(key, value, remappingFunction);
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
private void trackMergeParameters(final HashMap<String, Set<String>> mapping, final String source,
String destination) {
mapping.merge(destination, new HashSet<>(), (a, b) -> a).add(source);
}
代码示例来源:origin: org.jboss.da/reports-backend
@Override
public BinaryOperator<HashMap<Product, ProductArtifacts>> combiner() {
return (h, m) -> {
for(Map.Entry<Product, ProductArtifacts> e : m.entrySet()){
h.merge(e.getKey(), e.getValue(), (a, b) -> new ProductArtifacts(e.getKey(), combineSets(a.getArtifacts(), b.getArtifacts())));
}
return h;
};
}
代码示例来源:origin: io.snamp/internal-services
@Override
public final V merge(final K key, final V value, final BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
final V oldValue = get(key);
final V newValue = super.merge(key, value, remappingFunction);
//If value was changed after merge then mark this map as modified
markAsModified(!Objects.equals(oldValue, newValue));
return newValue;
}
代码示例来源:origin: RS485/LogisticsPipes
private void updateContents() {
_contentsMap.clear();
_contentsUndamagedSet.clear();
_contentsNoNBTSet.clear();
_contentsUndamagedNoNBTSet.clear();
for (ItemIdentifierStack _content : _contents) {
if (_content == null) continue;
ItemIdentifier itemId = _content.getItem();
_contentsMap.merge(itemId, _content.getStackSize(), (a, b) -> a + b);
_contentsUndamagedSet.add(itemId.getUndamaged()); // add is cheaper than check then add; it just returns false if it is already there
_contentsNoNBTSet.add(itemId.getIgnoringNBT()); // add is cheaper than check then add; it just returns false if it is already there
_contentsUndamagedNoNBTSet.add(itemId.getIgnoringNBT().getUndamaged()); // add is cheaper than check then add; it just returns false if it is already there
}
}
代码示例来源:origin: com.hotels.road/road-offramp-client
public static Flux<Map<Integer, Long>> fromMessages(@NonNull Flux<Message<?>> messages, @NonNull Duration interval) {
if (interval.toMillis() < 0L) {
throw new IllegalArgumentException("Must not be a negative interval.");
}
return messages
.window(interval)
.<Map<Integer, Long>> flatMap(
f -> f.collect(HashMap::new, (c, m) -> c.merge(m.getPartition(), m.getOffset() + 1L, Math::max)))
.filter(x -> !x.isEmpty());
}
}
代码示例来源:origin: MegaMek/megamek
public HashMap<String, Integer> getSalvage(int era) {
if (salvage.containsKey(era) && salvage.get(era).size() > 0) {
return salvage.get(era);
}
HashMap<String,Integer> retVal = new HashMap<String, Integer>();
if (retVal.size() == 0 && parentFactions.size() > 0) {
for (String pKey : parentFactions) {
FactionRecord fRec = RATGenerator.getInstance().getFaction(pKey);
if (fRec != null) {
for (String fKey : fRec.getSalvage(era).keySet()) {
retVal.merge(fKey, fRec.getSalvage(era).get(fKey), Integer::sum);
}
} else {
DefaultMmLogger.getInstance().debug(getClass(), "getSalvage(int)",
"RATGenerator: could not locate salvage faction " + pKey
+ " for " + key);
}
}
}
salvage.put(era, retVal);
return retVal;
}
代码示例来源:origin: RS485/LogisticsPipes
addedItems.merge(next.getKey(), next.getValue(), (a, b) -> a + b);
代码示例来源:origin: batfish/batfish
@Override
public Void visitShiftIpAddressIntoSubnet(
ShiftIpAddressIntoSubnet shiftIpAddressIntoSubnet) {
IpField ipField = shiftIpAddressIntoSubnet.getIpField();
BDD bdd = getIpSpaceToBDD(ipField).toBDD(shiftIpAddressIntoSubnet.getSubnet());
ranges.merge(ipField, bdd, BDD::or);
return null;
}
};
代码示例来源:origin: CogComp/talen
counts.merge(new Pair<>(f.getLabel(), label), 1., (oldValue, one) -> oldValue + one);
featcounts.merge(f.getLabel(), 1, (oldValue, one) -> oldValue + one);
代码示例来源:origin: org.jboss.da/reports-backend
@Override
public BiConsumer<HashMap<Product, ProductArtifacts>, Set<ProductArtifacts>> accumulator() {
return (h, m) -> {
for(ProductArtifacts pa : m){
h.merge(pa.getProduct(), pa, (a, b) -> new ProductArtifacts(pa.getProduct(), combineSets(a.getArtifacts(), b.getArtifacts())));
}
};
}
代码示例来源:origin: batfish/batfish
@Override
public Void visitAssignIpAddressFromPool(
AssignIpAddressFromPool assignIpAddressFromPool) {
IpField ipField = assignIpAddressFromPool.getIpField();
BDDInteger var = getIpSpaceToBDD(ipField).getBDDInteger();
BDD bdd =
var.geq(assignIpAddressFromPool.getPoolStart().asLong())
.and(var.leq(assignIpAddressFromPool.getPoolEnd().asLong()));
ranges.merge(ipField, bdd, BDD::or);
return null;
}
内容来源于网络,如有侵权,请联系作者删除!