Java Collection Element Get getAll(Map map, Collection indices)

Here you can find the source of getAll(Map map, Collection indices)

Description

Get all values corresponding to the indices (if they exist in the map).

License

Open Source License

Parameter

Parameter Description
map Any map from T to V
indices A collection of indices of type T

Return

The corresponding list of values of type V

Declaration

public static <T, V> List<V> getAll(Map<T, V> map, Collection<T> indices) 

Method Source Code

//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;
    }
}

Related

  1. get(Collection v, int i)
  2. get(final Collection list, final int pos)
  3. get(final Collection collection, final int index)
  4. getAddedItems(Collection oldValues, Collection newValues)
  5. getAdditions(Collection source, Collection target)
  6. getAllDoubleValues( Map>> doubleCollectionWithValuesToFetch)
  7. getAllTopicsAsString(final Collection topics)
  8. getAncestors(Collection> classes)
  9. getAnElement(Collection coll)