Java tutorial
//package com.java2s; import java.util.HashMap; import java.util.List; import java.util.Map; public class Main { public static <S> Map<Integer, S> asIndexMap(List<S> pList) { final HashMap<Integer, S> map = new HashMap<Integer, S>(pList.size()); for (final S s : pList) { map.put(pList.indexOf(s), s); } return map; } }