Example usage for java.util List addAll

List of usage examples for java.util List addAll

Introduction

In this page you can find the example usage for java.util List addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).

Usage

From source file:Main.java

/**
 * @return a list of live threads/*from   w w  w.  j  a  v a 2 s  . co  m*/
 */
public static List<Thread> getLiveThreads() {
    List<Thread> ret = new ArrayList<Thread>();
    ret.addAll(Thread.getAllStackTraces().keySet());
    return ret;
}

From source file:Main.java

public static <E> List<E> listOf(E... elements) {
    List<E> result = new ArrayList<E>(elements.length);
    result.addAll(Arrays.asList(elements));
    return result;
}

From source file:testReflection.java

public static Field[] getAllFields(Class klass) {
    List<Field> fields = new ArrayList<Field>();
    fields.addAll(Arrays.asList(klass.getDeclaredFields()));
    if (klass.getSuperclass() != null) {
        fields.addAll(Arrays.asList(getAllFields(klass.getSuperclass())));
    }//from   w w  w . j a v a2 s. com
    return fields.toArray(new Field[] {});
}

From source file:Main.java

/**
 * Concatenates two arrays.//from  ww  w .jav a 2 s.c  o  m
 * 
 * @param array1
 *            - first array
 * @param array2
 *            - second array
 * @param <T>
 *            - object class
 * @return array contatenation
 */
public static <T> T[] concatenate2Arrays(T[] array1, T... array2) {
    List<T> result = new ArrayList<T>();
    result.addAll(Arrays.asList(array1));
    result.addAll(Arrays.asList(array2));

    return result.toArray(array1);
}

From source file:Main.java

public static void copy(List<Integer> destList, List<Integer> srcList) {
    destList.clear();/*ww  w.  j a  va2  s  . c  o m*/
    destList.addAll(srcList);
}

From source file:Main.java

public static <T> List<T> clone(List<T> in) {
    List ret = new ArrayList();
    if (in != null) {
        ret.addAll(in);
    }/*from  w w w.  j a  va  2s.  c o m*/
    return ret;
}

From source file:Main.java

public static List removeDuplicate(List list) {
    HashSet h = new HashSet(list);
    list.clear();//from   w  w  w  .j a va  2s . co m
    list.addAll(h);
    return list;
}

From source file:Main.java

public static <T> List<T> clone(List<T> list) {
    List<T> clone = new ArrayList<T>(list.size());
    clone.addAll(list);
    return clone;
}

From source file:Main.java

private static <T> void permutationsImpl(List<Collection<T>> ori, Collection<List<T>> res, int d,
        List<T> current) {//from   w  w w  .j a  v a2s .c  om
    if (d == ori.size()) {
        res.add(current);
        return;
    }
    // iterate from current collection and copy 'current' element N times, one for each element
    Collection<T> currentCollection = ori.get(d);
    for (T element : currentCollection) {
        List<T> copy = new LinkedList<T>();
        copy.addAll(current);
        copy.add(element);
        permutationsImpl(ori, res, d + 1, copy);
    }
}

From source file:Main.java

public final static <T> List<T> unicon(List<T> list1, List<T> list2) {
    List<T> list = new ArrayList(list1.size() + list2.size());
    list.addAll(list1);
    list.addAll(list2);/*from  w w  w.j ava2 s .  co  m*/
    return list;
}