Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.Collection;

import java.util.List;
import java.util.Map;

public class Main {
    /**
     * get all values corresponding to the indices (if they exist in the map)
     * @param map
     * @param indices
     * @return
     */
    public static <T, V> List<V> getAll(Map<T, V> map, Collection<T> indices) {
        List<V> result = new ArrayList<V>();
        for (T i : indices)
            if (map.containsKey(i)) {
                result.add(map.get(i));
            }
        return result;
    }
}