zhiqinghuang / lambdaj

Automatically exported from code.google.com/p/lambdaj
Apache License 2.0
0 stars 0 forks source link

Feature request: convert both key and value when creating a map #84

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Feature request: convert both key and value when creating a map

public static <F, K, V> Map<K, V> map(
    Object iterable, 
    Converter<F, K> keyConverter, 
    Converter<F, V> valueConverter) {

    Map<K, V> map = new HashMap<K, V>();
    Iterator<F> i = (Iterator<F>)asIterator(iterable);
    while (i.hasNext()) {
        F item = i.next();
        map.put(
            keyConverter.convert(item),
            valueConverter.convert(item));
    }
    return map;
}

Original issue reported on code.google.com by lexicals...@gmail.com on 7 Feb 2012 at 1:20