本文整理汇总了Java中com.google.common.collect.BiMap.putAll方法的典型用法代码示例。如果您正苦于以下问题:Java BiMap.putAll方法的具体用法?Java BiMap.putAll怎么用?Java BiMap.putAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.BiMap
的用法示例。
在下文中一共展示了BiMap.putAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUpdateBiMapDate
import com.google.common.collect.BiMap; //导入方法依赖的package包/类
/**
* HashBiMap 修改数据
* putAll
* remove
* replace
*/
@Test
public void testUpdateBiMapDate() {
BiMap<String, String> biMap = HashBiMap.create();
biMap.put("k1", "v1");
biMap.put("k2", "v2");
// putAll , 存入另一个Map的数据,此时如果value有重复的依然会抛异常
biMap.putAll(ImmutableBiMap.of("k3", "v3", "k4", "v4", "k5", "v5", "k6", "v6"));
System.out.println("biMap putAll after: " + biMap);
System.out.println("\n-------------------------------------------\n");
// remove , 移除指定key的元素,如果key不存在,则返回null
String v2 = biMap.remove("k2");
String valueNotExists = biMap.remove("keyNotExists");
System.out.println("remove k2 then biMap= " + biMap + ", and remove the value= " + v2);
System.out.println("valueNotExists=" + valueNotExists);
System.out.println("\n-------------------------------------------\n");
// 清空map里的数据
biMap.clear();
System.out.println("clean biMap=" + biMap);
}
示例2: build
import com.google.common.collect.BiMap; //导入方法依赖的package包/类
ProtoRegistry build() {
ImmutableListMultimap<String, TypeModification> modificationsMap =
ImmutableListMultimap.copyOf(
this.typeModifications
.stream()
.map(
modification ->
new SimpleImmutableEntry<>(modification.getTypeName(), modification))
.collect(Collectors.toList()));
final BiMap<String, GraphQLType> mapping = HashBiMap.create();
GraphQLInterfaceType nodeInterface =
new Relay()
.nodeInterface(
env -> {
Relay.ResolvedGlobalId resolvedGlobalId =
new Relay().fromGlobalId(env.getArguments().get("id").toString());
return (GraphQLObjectType) mapping.get(resolvedGlobalId.getType());
});
mapping.putAll(
modifyTypes(
getMap(fileDescriptors, descriptors, enumDescriptors, nodeInterface),
modificationsMap));
return new ProtoRegistry(mapping, nodeInterface);
}
示例3: refine
import com.google.common.collect.BiMap; //导入方法依赖的package包/类
@Override
public Collection<? extends ProblemNeighborhoodAware<BiMap<V, V>, T>> refine(BiMap<V, V> partialSolution) {
BiMap<V, V> newBaseSolution = HashBiMap.create(baseSolution.size() + partialSolution.size());
newBaseSolution.putAll(baseSolution);
newBaseSolution.putAll(partialSolution);
return Collections.singleton(new ProblemNodeMappingGraph<>(newBaseSolution, viewGraph, queryGraph, nodeComparatorFactory, edgeComparatorFactory, skipIncompatibleMappings));
}