Convert Map<Integer, T> to Ordered List<T> - Java java.util

Java examples for java.util:List Convert

Description

Convert Map<Integer, T> to Ordered List<T>

Demo Code


//package com.java2s;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class Main {
    public final static <T> List<T> toOrderedList(
            final Map<Integer, T> responseMap) {
        final List<T> localResponses = new ArrayList<T>(
                responseMap.size());//from   w  w  w  .  j a  v a 2 s . c  o m
        for (int i = 0; i < responseMap.size(); i++) {
            final T rr = responseMap.get(Integer.valueOf(i));

            assert rr != null;

            localResponses.add(rr);
        }
        return localResponses;
    }
}

Related Tutorials