当前位置: 首页>>代码示例>>Java>>正文


Java BiMap.remove方法代码示例

本文整理汇总了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);
}
 
开发者ID:cbooy,项目名称:cakes,代码行数:31,代码来源:HashBiMapDemo.java

示例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();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:45,代码来源:FluidRegistry.java


注:本文中的com.google.common.collect.BiMap.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。