Here you can find the source of listToMap(List
Parameter | Description |
---|---|
list | a parameter |
private static <A, B> Map<A, B> listToMap(List<Map.Entry<A, B>> list)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; public class Main { /**//from ww w . j a v a 2s . c om * Puts the entries in {@code list} into a {@code Map}. The returned map has * the same iteration order over entries as {@code list}. * * @param list * @return */ private static <A, B> Map<A, B> listToMap(List<Map.Entry<A, B>> list) { Map<A, B> result = new LinkedHashMap<A, B>(); for (Iterator<Map.Entry<A, B>> it = list.iterator(); it.hasNext();) { Map.Entry<A, B> entry = (Map.Entry<A, B>) it.next(); result.put(entry.getKey(), entry.getValue()); } return result; } }