Java HashMap Create toHashMap(ArrayList list, int beginId)

Here you can find the source of toHashMap(ArrayList list, int beginId)

Description

to Hash Map

License

Open Source License

Return

HashMap whose keys are strings from list and values are sequential integers starting at beginId

Declaration

static public HashMap<String, Integer> toHashMap(ArrayList<String> list, int beginId) 

Method Source Code


//package com.java2s;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
    /** @return HashMap whose keys are strings from <code>list</code> and values are sequential integers starting at <code>beginId</code> */
    static public HashMap<String, Integer> toHashMap(ArrayList<String> list, int beginId) {
        HashMap<String, Integer> map = new HashMap<String, Integer>(list.size());

        for (int i = 0; i < list.size(); i++)
            map.put(list.get(i), i + beginId);

        return map;
    }/*from  w w  w  . ja  v a 2s  . com*/
}

Related

  1. newHashMap(Map m)
  2. newHashMap(Object... kv)
  3. newHashMap(T key, U value)
  4. newHashMapWithCapacity(int expectedSize, float loadFactor)
  5. toHashMap( Entry[] entries)
  6. toHashMap(final Map map)
  7. toHashMapStrObj(Object object)