本文整理汇总了Java中com.google.common.collect.BiMap.remove方法的典型用法代码示例。如果您正苦于以下问题:Java BiMap.remove方法的具体用法?Java BiMap.remove怎么用?Java BiMap.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.BiMap
的用法示例。
在下文中一共展示了BiMap.remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: loadFluidDefaults
import com.google.common.collect.BiMap; //导入方法依赖的package包/类
/**
* Called by forge to load default fluid IDs from the world or from server -> client for syncing
* DO NOT call this and expect useful behaviour.
* @param localFluidIDs
* @param defaultNames
*/
private static void loadFluidDefaults(BiMap<Fluid, Integer> localFluidIDs, Set<String> defaultNames)
{
// If there's an empty set of default names, use the defaults as defined locally
if (defaultNames.isEmpty()) {
defaultNames.addAll(defaultFluidName.values());
}
BiMap<String, Fluid> localFluids = HashBiMap.create(fluids);
for (String defaultName : defaultNames)
{
Fluid fluid = masterFluidReference.get(defaultName);
if (fluid == null) {
String derivedName = defaultName.split(":",2)[1];
String localDefault = defaultFluidName.get(derivedName);
if (localDefault == null) {
FMLLog.getLogger().log(Level.ERROR, "The fluid {} (specified as {}) is missing from this instance - it will be removed", derivedName, defaultName);
continue;
}
fluid = masterFluidReference.get(localDefault);
FMLLog.getLogger().log(Level.ERROR, "The fluid {} specified as default is not present - it will be reverted to default {}", defaultName, localDefault);
}
FMLLog.getLogger().log(Level.DEBUG, "The fluid {} has been selected as the default fluid for {}", defaultName, fluid.getName());
Fluid oldFluid = localFluids.put(fluid.getName(), fluid);
Integer id = localFluidIDs.remove(oldFluid);
localFluidIDs.put(fluid, id);
}
BiMap<Integer, String> localFluidNames = HashBiMap.create();
for (Entry<Fluid, Integer> e : localFluidIDs.entrySet()) {
localFluidNames.put(e.getValue(), e.getKey().getName());
}
fluidIDs = localFluidIDs;
fluids = localFluids;
fluidNames = localFluidNames;
fluidBlocks = null;
for (FluidDelegate fd : delegates.values())
{
fd.rebind();
}
}