Here you can find the source of getAll(Map
Parameter | Description |
---|---|
map | Any map from T to V |
indices | A collection of indices of type T |
public static <T, V> List<V> getAll(Map<T, V> map, Collection<T> indices)
//package com.java2s; import java.util.*; public class Main { /**//from w w w .j a v a 2s. c om * Get all values corresponding to the indices (if they exist in the map). * * @param map Any map from T to V * @param indices A collection of indices of type T * @return The corresponding list of values of type V */ public static <T, V> List<V> getAll(Map<T, V> map, Collection<T> indices) { List<V> result = new ArrayList<>(); for (T i : indices) if (map.containsKey(i)) { result.add(map.get(i)); } return result; } }