All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.imsejin.common.util.CollectionUtils Maven / Gradle / Ivy

package io.github.imsejin.common.util;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * Collection utilities
 */
public final class CollectionUtils {

    private CollectionUtils() {}

    /**
     * Converts collection into map whose key is index and value is list's.
     *
     * 
{@code
     *     List list = Arrays.asList("A", "B", "C");
     *     toMap(list); // {0: "A", 1: "B", 2: "C"}
     * }
* * @param c collection * @param type of element * @return map with index as key and element */ public static Map toMap(Collection c) { return c.stream().collect(HashMap::new, (map, streamValue) -> map.put(map.size(), streamValue), (map, map2) -> {}); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy