Java Set to List convertToList(Set set)

Here you can find the source of convertToList(Set set)

Description

Converts a set of objects to a list of objects.

License

BSD License

Parameter

Parameter Description
T a parameter
set the set to be converted.

Return

list of objects

Declaration

public static <T> List<T> convertToList(Set<T> set) 

Method Source Code


//package com.java2s;
/*L/*from   w  w  w  . j a v  a2 s.  c  om*/
 *  Copyright Ekagra Software Technologies Ltd.
 *  Copyright SAIC, SAIC-Frederick
 *
 *  Distributed under the OSI-approved BSD 3-Clause License.
 *  See http://ncip.github.com/cacore-sdk/LICENSE.txt for details.
 */

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import java.util.Set;

public class Main {
    /**
     * Converts a set of objects to a list of objects.
     * @param <T>
     * 
     * @param set the set to be converted.
     * @return list of objects
     */
    public static <T> List<T> convertToList(Set<T> set) {
        if (set == null)
            return null;
        List<T> list = new ArrayList<T>(set.size());
        Iterator<T> it = set.iterator();
        while (it.hasNext()) {
            list.add(it.next());
        }
        return list;
    }
}

Related

  1. convertSetToList(Set set)
  2. convertSetToList(Set typeSet)
  3. convertSetToList(Set set)
  4. convertToList(Set set)
  5. setToList(Set set)
  6. setToList(Set set)
  7. setToList(Set set)