List of usage examples for java.util Map values
Collection<V> values();
From source file:Main.java
public static <K, V> List<V> toValueList(Map<K, V> map) { return new ArrayList<V>(map.values()); }
From source file:Main.java
/** * Returns map values list.//from w w w . j av a2s . c o m * * @param map map to process * @param <K> key object type * @param <V> value object type * @return map values list */ public static <K, V> ArrayList<V> valuesList(final Map<K, V> map) { return new ArrayList<V>(map.values()); }
From source file:Main.java
/** * Removes null values from the given map *///from www . ja v a 2 s . com public static void removeNullValues(Map<String, ?> map) { if (map == null) return; map.values().removeAll(Collections.singleton(null)); }
From source file:Main.java
/** * Applies a function to the values of the map. Note: Uses a for-each loop. * * @param map The map with the values the function will be applied to. * @param function The function to apply. *///from w w w . jav a 2 s . c o m public static <I, V extends I> void applyToValues(Map<?, V> map, Function<I, ?> function) { for (V value : map.values()) function.apply(value); }
From source file:Main.java
public static <K, V> List<V> mapConvertToList(Map<K, V> map) { List<V> list = new ArrayList<V>(); for (V value : map.values()) { list.add(value);/*from www . ja v a 2 s. c o m*/ } return list; }
From source file:Main.java
private static Double calculateMagnitude(Map<Object, Integer> map1) { Double sum = 0.0;/*w w w . j a v a2s. c om*/ for (Integer value : map1.values()) { sum += Math.pow(value, 2); } return Math.sqrt(sum); }
From source file:Main.java
public static Object extractSingleMapRoot(Map map) { if (map.size() == 1) { Object root = map.values().iterator().next(); return root; }/*w w w .j a v a2 s . c om*/ return map; }
From source file:com.microsoft.azure.shortcuts.resources.samples.SizesSample.java
public static void test(Subscription subscription) throws Exception { // List size names in a specific region Set<String> sizeNames = subscription.sizes().asMap("westus").keySet(); System.out.println("VM sizes: \n\t" + StringUtils.join(sizeNames, ",\n\t")); // List sizes in a specific region Map<String, Size> sizes = subscription.sizes().asMap("westus"); for (Size size : sizes.values()) { System.out.println(String.format( "VM size: %s\n" + "\tMax data disk count: %d\n" + "\tMemory in MB: %d\n" + "\tNumber of cores: %d\n" + "\tOS disk size in MB: %d\n" + "\tResource disk size in MB: %d\n", size.id(), size.maxDataDiskCount(), size.memoryInMB(), size.numberOfCores(), size.osDiskSizeInMB(), size.resourceDiskSizeInMB())); }/*from w w w . j av a 2 s .c o m*/ }
From source file:Main.java
public static void listValues(Map<String, String> map) { System.out.println("Values Collection:"); Collection<String> values = map.values(); values.forEach(System.out::println); System.out.println();/*w w w . ja va 2 s .c om*/ }
From source file:Main.java
/** * Sums up all the associated values from the specified * <code>map</code>/*from w w w. j ava 2 s . c om*/ * @param map * @return */ public static <K> double sum(Map<K, ? extends Number> map) { double sum = 0.0; for (Number value : map.values()) { sum += value.doubleValue(); } return sum; }