本文整理匯總了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));
}