當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。