當前位置: 首頁>>代碼示例>>Java>>正文


Java BiMap類代碼示例

本文整理匯總了Java中com.google.common.collect.BiMap的典型用法代碼示例。如果您正苦於以下問題:Java BiMap類的具體用法?Java BiMap怎麽用?Java BiMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BiMap類屬於com.google.common.collect包,在下文中一共展示了BiMap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import com.google.common.collect.BiMap; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void onCreate(Map<ResourceLocation, ?> slaveset, BiMap<ResourceLocation, ? extends IForgeRegistry<?>> registries)
{
    final ClearableObjectIntIdentityMap<IBlockState> idMap = new ClearableObjectIntIdentityMap<IBlockState>()
    {
        @SuppressWarnings("deprecation")
        @Override
        public int get(IBlockState key)
        {
            Integer integer = (Integer)this.identityMap.get(key);
            // There are some cases where this map is queried to serialize a state that is valid,
            //but somehow not in this list, so attempt to get real metadata. Doing this hear saves us 7 patches
            if (integer == null && key != null)
                integer = this.identityMap.get(key.getBlock().getStateFromMeta(key.getBlock().getMetaFromState(key)));
            return integer == null ? -1 : integer.intValue();
        }
    };
    ((Map<ResourceLocation,Object>)slaveset).put(BLOCKSTATE_TO_ID, idMap);
    final HashBiMap<Block, Item> map = HashBiMap.create();
    ((Map<ResourceLocation,Object>)slaveset).put(BLOCK_TO_ITEM, map);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:GameData.java

示例2: SoundManager

import com.google.common.collect.BiMap; //導入依賴的package包/類
public SoundManager(SoundHandler p_i45119_1_, GameSettings p_i45119_2_)
{
    this.invPlayingSounds = ((BiMap)this.playingSounds).inverse();
    this.playingSoundPoolEntries = Maps.<ISound, SoundPoolEntry>newHashMap();
    this.categorySounds = HashMultimap.<SoundCategory, String>create();
    this.tickableSounds = Lists.<ITickableSound>newArrayList();
    this.delayedSounds = Maps.<ISound, Integer>newHashMap();
    this.playingSoundsStopTime = Maps.<String, Integer>newHashMap();
    this.sndHandler = p_i45119_1_;
    this.options = p_i45119_2_;

    try
    {
        SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class);
        SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
    }
    catch (SoundSystemException soundsystemexception)
    {
        logger.error(LOG_MARKER, (String)"Error linking with the LibraryJavaSound plug-in", (Throwable)soundsystemexception);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:22,代碼來源:SoundManager.java

示例3: configureResourceSetContainerState

import com.google.common.collect.BiMap; //導入依賴的package包/類
private void configureResourceSetContainerState(final List<N4JSProject> allProjects) {
	// a container is a project.
	List<String> containers = new LinkedList<>();
	BiMap<String, N4JSProject> container2project = HashBiMap.create();

	// the URIs of all resources directly contained in a project/container.
	Multimap<String, URI> container2Uris = HashMultimap.create();

	for (N4JSProject project : allProjects) {
		String container = FileBasedWorkspace.N4FBPRJ + project.getLocation();
		container2project.put(container, project);
		containers.add(container);

		for (IN4JSSourceContainer sourceContainer : project.getSourceContainers()) {
			Iterables.addAll(container2Uris.get(container), sourceContainer);
		}
	}

	// Define the Mapping of Resources (URIs to Container === Projects),
	rsbAcs.configure(containers, container2Uris);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:22,代碼來源:N4HeadlessCompiler.java

示例4: testConflictInsertKV

import com.google.common.collect.BiMap; //導入依賴的package包/類
/**
 * BiMap存儲數據時出現衝突
 * 存儲時,如果key相同,則會覆蓋,則逆轉後不會有問題
 * 存儲時,如果key不同,value有相同,則逆轉時會拋出異常IllegalArgumentException
 */
@Test
public void testConflictInsertKV() {
    // 存儲相同key數據,此時會覆蓋k1=v1
    BiMap<String, String> biMap1 = HashBiMap.create();
    biMap1.put("k1", "v1");
    biMap1.put("k1", "v2");
    System.out.println("biMap1: " + biMap1);

    // 獲取的隻有 v2=k1
    BiMap<String, String> inverseBiMap1 = biMap1.inverse();
    System.out.println("inverseBiMap1: " + inverseBiMap1);

    System.out.println("--------------------------------------");

    // 存儲相同的value數據
    BiMap<String, String> biMap2 = HashBiMap.create();
    biMap2.put("k1", "v1");

    // 此時拋出異常 java.lang.IllegalArgumentException: value already present: v1
    biMap2.put("k2", "v1");
    System.out.println("biMap2: " + biMap2);

    BiMap<String, String> inverseBiMap2 = biMap2.inverse();
    System.out.println("inverseBiMap2: " + inverseBiMap2);
}
 
開發者ID:cbooy,項目名稱:cakes,代碼行數:31,代碼來源:HashBiMapDemo.java

示例5: fixOids

import com.google.common.collect.BiMap; //導入依賴的package包/類
@SuppressWarnings("rawtypes")
private void fixOids(IdEObject idEObject, OidProvider oidProvider, BiMap<Long, IdEObject> temp) {
	if (idEObject == null) {
		return;
	}
	if (temp.containsValue(idEObject)) {
		return;
	}
	((IdEObjectImpl) idEObject).setOid(oidProvider.newOid(idEObject.eClass()));
	if (objects.containsValue(idEObject)) {
		temp.put(idEObject.getOid(), idEObject);
	}
	for (EReference eReference : idEObject.eClass().getEAllReferences()) {
		Object val = idEObject.eGet(eReference);
		if (eReference.isMany()) {
			List list = (List) val;
			for (Object o : list) {
				fixOids((IdEObject) o, oidProvider, temp);
			}
		} else {
			fixOids((IdEObject) val, oidProvider, temp);
		}
	}
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:25,代碼來源:IfcModel.java

示例6: onSubstituteActivated

import com.google.common.collect.BiMap; //導入依賴的package包/類
@Override
public void onSubstituteActivated(Map<ResourceLocation, ?> slaveset, Block original, Block replacement, ResourceLocation name)
{
    final BiMap<Block, Item> blockItemMap = (BiMap<Block, Item>)slaveset.get(BLOCK_TO_ITEM);
    if (blockItemMap.containsKey(original))
    {
        Item i = blockItemMap.get(original);
        if (i instanceof ItemBlock)
        {
            try
            {
                FinalFieldHelper.setField(blockField, i, replacement);
            }
            catch (Exception e)
            {
                throw Throwables.propagate(e);
            }
        }
        blockItemMap.forcePut(replacement,i);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:22,代碼來源:GameData.java

示例7: getUnmappedMethodMapping

import com.google.common.collect.BiMap; //導入依賴的package包/類
public Optional<MethodRef> getUnmappedMethodMapping(CtClass targetClass, CtMethod
        handleMethod) {
    BiMap<MethodRef, MethodRef> methodsInverted = methodRefs.inverse();
    String descriptor = InjectorPlugin.removeCallbackDescriptor(handleMethod.getMethodInfo2()
            .getDescriptor());
    for (Map.Entry<MethodRef, MethodRef> mapping : methodsInverted.entrySet()) {
        MethodRef key = mapping.getKey();
        if (targetClass.getName().replace('.', '/').equals(key.getOwner()) && handleMethod
                .getName
                ().equals
                (key
                .getName()) && descriptor.equals(key.getDesc())) {
            return Optional.of(mapping.getValue());
        }
    }
    return Optional.empty();
}
 
開發者ID:PizzaCrust,項目名稱:Mixinite,代碼行數:18,代碼來源:Mappings.java

示例8: modifyTypes

import com.google.common.collect.BiMap; //導入依賴的package包/類
/** Applies the supplied modifications to the GraphQLTypes. */
private static BiMap<String, GraphQLType> modifyTypes(
    BiMap<String, GraphQLType> mapping,
    ImmutableListMultimap<String, TypeModification> modifications) {
  BiMap<String, GraphQLType> result = HashBiMap.create(mapping.size());
  for (String key : mapping.keySet()) {
    if (mapping.get(key) instanceof GraphQLObjectType) {
      GraphQLObjectType val = (GraphQLObjectType) mapping.get(key);
      if (modifications.containsKey(key)) {
        for (TypeModification modification : modifications.get(key)) {
          val = modification.apply(val);
        }
      }
      result.put(key, val);
    } else {
      result.put(key, mapping.get(key));
    }
  }
  return result;
}
 
開發者ID:google,項目名稱:rejoiner,代碼行數:21,代碼來源:ProtoRegistry.java

示例9: expectMissing

import com.google.common.collect.BiMap; //導入依賴的package包/類
@Override
protected void expectMissing(Entry<K, V>... entries) {
  super.expectMissing(entries);
  for (Entry<K, V> entry : entries) {
    Entry<V, K> reversed = reverseEntry(entry);
    BiMap<V, K> inv = getMap().inverse();
    assertFalse(
        "Inverse should not contain entry " + reversed, inv.entrySet().contains(reversed));
    assertFalse(
        "Inverse should not contain key " + reversed.getKey(),
        inv.containsKey(reversed.getKey()));
    assertFalse(
        "Inverse should not contain value " + reversed.getValue(),
        inv.containsValue(reversed.getValue()));
    /*
     * TODO(cpovirk): This is a bit stronger than super.expectMissing(), which permits a <key,
     * someOtherValue> pair.
     */
    assertNull(
        "Inverse should not return a mapping for key " + reversed.getKey(),
        inv.get(reversed.getKey()));
  }
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:24,代碼來源:AbstractBiMapTester.java

示例10: SoundManager

import com.google.common.collect.BiMap; //導入依賴的package包/類
public SoundManager(SoundHandler p_i45119_1_, GameSettings p_i45119_2_)
{
    this.invPlayingSounds = ((BiMap)this.playingSounds).inverse();
    this.categorySounds = HashMultimap.<SoundCategory, String>create();
    this.tickableSounds = Lists.<ITickableSound>newArrayList();
    this.delayedSounds = Maps.<ISound, Integer>newHashMap();
    this.playingSoundsStopTime = Maps.<String, Integer>newHashMap();
    this.listeners = Lists.<ISoundEventListener>newArrayList();
    this.pausedChannels = Lists.<String>newArrayList();
    this.sndHandler = p_i45119_1_;
    this.options = p_i45119_2_;

    try
    {
        SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class);
        SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
        net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.SoundSetupEvent(this));
    }
    catch (SoundSystemException soundsystemexception)
    {
        LOGGER.error(LOG_MARKER, (String)"Error linking with the LibraryJavaSound plug-in", (Throwable)soundsystemexception);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:24,代碼來源:SoundManager.java

示例11: getTrainsFollowingEachOther

import com.google.common.collect.BiMap; //導入依賴的package包/類
public BiMap<Train, Train> getTrainsFollowingEachOther() {
  if (false && trailingTrains.size() + 1 == world.getTrains().size()) {
    return trailingTrains;
  }
  trailingTrains.clear();

  Map<Journey, Journey> journeyTrail = getJourneysFollowingEachOther();
  journeyTrail.forEach((key, value) -> trailingTrains.put(key.getTrain(), value.getTrain()));

  return trailingTrains;
}
 
開發者ID:sinaa,項目名稱:train-simulator,代碼行數:12,代碼來源:JourneyHelper.java

示例12: match

import com.google.common.collect.BiMap; //導入依賴的package包/類
@Override
public Iterable<BiMap<V, V>> match(BiMap<V, V> baseIso, G viewGraph, G insertGraph) {
    ProblemNeighborhoodAware<BiMap<V, V>, V> problem = toProblem(baseIso, viewGraph, insertGraph);
    Iterable<BiMap<V, V>> result = () -> problem.generateSolutions().iterator();

    return result;
}
 
開發者ID:SmartDataAnalytics,項目名稱:SubgraphIsomorphismIndex,代碼行數:8,代碼來源:IsoMatcherJena.java

示例13: registerSubstitutionAlias

import com.google.common.collect.BiMap; //導入依賴的package包/類
void registerSubstitutionAlias(String name, GameRegistry.Type type, Object toReplace) throws ExistingSubstitutionException
{
    ResourceLocation nameToSubstitute = new ResourceLocation(name);
    final BiMap<Block, Item> blockItemMap = getBlockItemMap();
    if (type == GameRegistry.Type.BLOCK)
    {
        iBlockRegistry.addSubstitutionAlias(Loader.instance().activeModContainer().getModId(), nameToSubstitute, (Block)toReplace);
        iBlockRegistry.activateSubstitution(nameToSubstitute);
    }
    else if (type == GameRegistry.Type.ITEM)
    {
        iItemRegistry.addSubstitutionAlias(Loader.instance().activeModContainer().getModId(), nameToSubstitute, (Item)toReplace);
        iItemRegistry.activateSubstitution(nameToSubstitute);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:16,代碼來源:GameData.java

示例14: getTypeMap

import com.google.common.collect.BiMap; //導入依賴的package包/類
public static BiMap<String, Integer> getTypeMap()
{
	BiMap<String, Integer> typeMap = HashBiMap.create();
	typeMap.put(ITEM_NODE_TYPE, ITEM_TYPE);
	typeMap.put(PARALLEL_NODE_TYPE, PARALLEL_TYPE);
	typeMap.put(SERIAL_NODE_TYPE, SERIAL_TYPE);
	typeMap.put(DECISION_NODE_TYPE, DECISION_TYPE);
	return typeMap;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:10,代碼來源:WorkflowNode.java

示例15: dump

import com.google.common.collect.BiMap; //導入依賴的package包/類
public synchronized void dump(Writer writer) throws IOException {
    for (Map.Entry<S, BiMap<String, Integer>> entry : id2num.entrySet()) {
        S subset = entry.getKey();
        for (Map.Entry<String, Integer> entry1 : entry.getValue().entrySet()) {
            String id = entry1.getKey();
            Integer num = entry1.getValue();
            writer.write(subset + ";" + id + ";" + num + System.lineSeparator());
        }
    }
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:11,代碼來源:StringToIntMapper.java


注:本文中的com.google.common.collect.BiMap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。