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


Java EnumMap.entrySet方法代码示例

本文整理汇总了Java中java.util.EnumMap.entrySet方法的典型用法代码示例。如果您正苦于以下问题:Java EnumMap.entrySet方法的具体用法?Java EnumMap.entrySet怎么用?Java EnumMap.entrySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.EnumMap的用法示例。


在下文中一共展示了EnumMap.entrySet方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.util.EnumMap; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    final EnumMap<TestEnum, String> enumMap = new EnumMap<>(TestEnum.class);

    for (TestEnum e : TestEnum.values()) {
        enumMap.put(e, e.name());
    }

    Set<Map.Entry<TestEnum, String>> entrySet = enumMap.entrySet();
    HashSet<Map.Entry<TestEnum, String>> hashSet = new HashSet<>(entrySet);

    if (false == hashSet.equals(entrySet)) {
        throw new RuntimeException("Test FAILED: Sets are not equal.");
    }
    if (hashSet.hashCode() != entrySet.hashCode()) {
        throw new RuntimeException("Test FAILED: Set's hashcodes are not equal.");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:DistinctEntrySetElements.java

示例2: createResolvedMetaData

import java.util.EnumMap; //导入方法依赖的package包/类
private DefaultLibraryLocalComponentMetadata createResolvedMetaData(BinarySpecInternal selectedBinary, String projectPath, EnumMap<UsageKind, Iterable<DependencySpec>> dependenciesPerUsage, EnumMap<UsageKind, List<PublishArtifact>> artifacts) {

        DefaultLibraryLocalComponentMetadata metadata = newResolvedLibraryMetadata(selectedBinary.getId(), toStringMap(dependenciesPerUsage), projectPath);
        for (Map.Entry<UsageKind, List<PublishArtifact>> entry : artifacts.entrySet()) {
            UsageKind usage = entry.getKey();
            List<PublishArtifact> publishArtifacts = entry.getValue();
            metadata.addArtifacts(usage.getConfigurationName(), publishArtifacts);
        }
        return metadata;
    }
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:11,代码来源:JvmLocalLibraryMetaDataAdapter.java

示例3: toStringMap

import java.util.EnumMap; //导入方法依赖的package包/类
private <T> Map<String, T> toStringMap(EnumMap<? extends Enum<UsageKind>, T> enumMap) {
    Map<String, T> map = new HashMap<String, T>(enumMap.size());
    for (Map.Entry<? extends Enum<UsageKind>, T> tEntry : enumMap.entrySet()) {
        UsageKind usageKind = UsageKind.valueOf(tEntry.getKey().name());
        map.put(usageKind.getConfigurationName(), tEntry.getValue());
    }
    return map;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:JvmLocalLibraryMetaDataAdapter.java

示例4: copyOfEnumMap

import java.util.EnumMap; //导入方法依赖的package包/类
private static <K extends Enum<K>, V> ImmutableMap<K, V> copyOfEnumMap(
    Map<K, ? extends V> original) {
  EnumMap<K, V> copy = new EnumMap<K, V>(original);
  for (Map.Entry<?, ?> entry : copy.entrySet()) {
    checkEntryNotNull(entry.getKey(), entry.getValue());
  }
  return ImmutableEnumMap.asImmutable(copy);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:9,代码来源:ImmutableMap.java

示例5: removeFishToken

import java.util.EnumMap; //导入方法依赖的package包/类
public void removeFishToken(EnumMap<FishTokenType, Integer> fishTokenToRemove) {
    for (EnumMap.Entry<FishTokenType, Integer> entry : fishTokenToRemove.entrySet()) {
        int newCount = fishTokenHand.get(entry.getKey()) - entry.getValue();
        if (newCount < 0) {
            throw new RuntimeException("FishToken count is below 0");
        }
        fishTokenHand.put(entry.getKey(), newCount);
    }
}
 
开发者ID:teobaranga,项目名称:Catan,代码行数:10,代码来源:Player.java

示例6: copyOfEnumMap

import java.util.EnumMap; //导入方法依赖的package包/类
private static <K extends Enum<K>, V> ImmutableMap<K, V> copyOfEnumMap(
    EnumMap<K, ? extends V> original) {
  EnumMap<K, V> copy = new EnumMap<>(original);
  for (Map.Entry<?, ?> entry : copy.entrySet()) {
    checkEntryNotNull(entry.getKey(), entry.getValue());
  }
  return ImmutableEnumMap.asImmutable(copy);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:9,代码来源:ImmutableMap.java

示例7: copyOfEnumMap

import java.util.EnumMap; //导入方法依赖的package包/类
private static <K extends Enum<K>, V> ImmutableMap<K, V> copyOfEnumMap(
    EnumMap<K, ? extends V> original) {
  EnumMap<K, V> copy = new EnumMap<K, V>(original);
  for (Map.Entry<?, ?> entry : copy.entrySet()) {
    checkEntryNotNull(entry.getKey(), entry.getValue());
  }
  return ImmutableEnumMap.asImmutable(copy);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:9,代码来源:ImmutableMap.java

示例8: ChooseMultipleResourcesWindow

import java.util.EnumMap; //导入方法依赖的package包/类
public ChooseMultipleResourcesWindow(String title, Skin skin, EnumMap<ResourceKind, Integer> cards, int number) {
	super(title, skin);
       
       widgets = new ArrayList<>();
       int tableWidth = 0;
       
       // create widget for each kind
       for (Entry<ResourceKind, Integer> entry : cards.entrySet()) {
       	if (entry.getValue() <= 0) {continue;}
           
       	ResourceWidget widget = new ResourceWidget(entry.getKey(), skin);
       	widget.setMaxResource(entry.getValue());
       	widgets.add(widget);
       	add(widget).padTop(10);
       	
       	tableWidth += widget.getPrefWidth() + 10;
       }

       // create button to confirm choice
       confirm = new TextButton("confirm", skin);
       confirm.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
               if (chooseCardsListener != null && getResourceCount() == number) {
				chooseCardsListener.onMapChosen(getResources());
                   remove();
               } 
		}
       });
       
       // set width and height
       width = tableWidth;
       int tableHeight = 100;
       if (widgets.size() > 0) {
       	tableHeight += widgets.get(0).getPrefHeight();
       }
       height = tableHeight;
       setWidth(width);
       setHeight(height);

       // add confirm button
       row();
       add(confirm).colspan(widgets.size()).padTop(10).align(Align.right);
       
       // set position on screen
       setPosition(Gdx.graphics.getWidth() / 2 - getWidth() / 2, Gdx.graphics.getHeight() / 2 - getHeight() / 2);
       
       // enable moving the window
       setMovable(true);
}
 
开发者ID:teobaranga,项目名称:Catan,代码行数:51,代码来源:ChooseMultipleResourcesWindow.java


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