Here you can find the source of convertToList(Set
Parameter | Description |
---|---|
T | a parameter |
set | the set to be converted. |
public static <T> List<T> convertToList(Set<T> set)
//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; } }