Example usage for java.util ArrayList addAll

List of usage examples for java.util ArrayList addAll

Introduction

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

Prototype

public 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.

Usage

From source file:Main.java

@SafeVarargs
public static <T> ArrayList<T> flattenList(List<T>... instancesList) {
    int size = 0;
    for (List<T> list : instancesList) {
        size += list.size();/*from  w  w  w  . j a  v  a  2 s  .c o m*/
    }

    ArrayList<T> flattened = new ArrayList<>(size);
    for (List<T> list : instancesList) {
        flattened.addAll(list);
    }

    return flattened;
}

From source file:Main.java

public static <E> ArrayList<E> asArrayList(E first, E... other) {
    if (other == null) {
        throw new NullPointerException("other");
    }/* w  ww. ja  v a  2s . c  om*/
    ArrayList<E> list = new ArrayList<>(1 + other.length);
    list.add(first);
    list.addAll(Arrays.asList(other));
    return list;
}

From source file:com.sec.ose.osi.util.tools.Tools.java

public static ArrayList<String> sortByValue(final HashMap<String, Integer> map) {
    ArrayList<String> key = new ArrayList<String>();
    key.addAll(map.keySet());
    Collections.sort(key, new Comparator<Object>() {
        public int compare(Object o1, Object o2) {
            Integer v1 = map.get(o1);
            Integer v2 = map.get(o2);
            return v1.compareTo(v2);
        }/*w w w .jav a 2  s .c  om*/
    });
    Collections.reverse(key);
    return key;
}

From source file:Main.java

public static int countDiffElmts(ArrayList<String> u, ArrayList<String> v) {
    ArrayList<String> listOne = new ArrayList<String>();
    ArrayList<String> listTwo = new ArrayList<String>();
    listOne.addAll(u);
    listOne.retainAll(v);//from w  w w  .j  av  a2 s .c  o  m
    listTwo.addAll(u);
    listTwo.addAll(v);
    listTwo.removeAll(listOne);
    return listTwo.size();
}

From source file:com.thoughtworks.go.util.ArrayUtil.java

public static <T> List<T> asList(T... a) {
    if (a == null) {
        return new ArrayList<T>();
    }//from  w ww.  ja  v  a 2  s.co m

    ArrayList<T> list = new ArrayList<T>(a.length);
    list.addAll(Arrays.asList(a));
    return list;
}

From source file:com.acme.spring.jms.Deployments.java

/**
 * <p>Retrieves the dependencies.</p>
 *
 * @return the array of the dependencies
 *//*from   w  w  w .  j a v  a2s .c  om*/
public static File[] springDependencies() {

    ArrayList<File> files = new ArrayList<File>();

    files.addAll(resolveDependencies("org.springframework:spring-context:3.1.1.RELEASE"));
    files.addAll(resolveDependencies("org.springframework:spring-jms:3.1.1.RELEASE"));

    return files.toArray(new File[files.size()]);
}

From source file:Main.java

public static <T> ArrayList<T> shuffle(ArrayList<T> population, int sample) {
    ArrayList<T> newList = new ArrayList<T>();
    ArrayList<T> ret = new ArrayList<T>();
    newList.addAll(population);

    Collections.shuffle(newList);
    ret.addAll(newList);//  w  w w . j  av a2s .c  o  m
    for (int i = sample; i < ret.size(); i++) {
        ret.remove(i);
        i--;
    }
    newList.clear();
    return ret;
}

From source file:com.acme.spring.jdbc.Deployments.java

/**
 * <p>Retrieves the dependencies.</p>
 *
 * @return the array of the dependencies
 *///from  ww  w.  j  a va 2s. c o  m
public static File[] springDependencies() {

    ArrayList<File> files = new ArrayList<File>();

    files.addAll(resolveDependencies("org.springframework:spring-context:3.1.1.RELEASE"));
    files.addAll(resolveDependencies("org.springframework:spring-jdbc:3.1.1.RELEASE"));
    files.addAll(resolveDependencies("org.springframework:spring-tx:3.1.1.RELEASE"));

    return files.toArray(new File[files.size()]);
}

From source file:com.acme.spring.jpa.Deployments.java

/**
 * <p>Retrieves the dependencies.</p>
 *
 * @return the array of the dependencies
 *///from   w  w  w. j  av a2  s  .  co  m
public static File[] springDependencies() {

    ArrayList<File> files = new ArrayList<File>();

    files.addAll(resolveDependencies("org.springframework:spring-context:3.1.1.RELEASE"));
    files.addAll(resolveDependencies("org.springframework:spring-orm:3.1.1.RELEASE"));
    files.addAll(resolveDependencies("org.springframework:spring-tx:3.1.1.RELEASE"));

    return files.toArray(new File[files.size()]);
}

From source file:Main.java

private static void getIndexSublist(int numbers, int length, List<List<Integer>> result) {

    List<List<Integer>> results = new ArrayList<>();
    results.addAll(result);//  w w w .ja  v  a 2s  . c o  m

    if (result.get(0).size() == length) {
        return;
    }

    result.clear();
    for (List<Integer> one : results) {

        for (int i = 1; i < numbers; i++) {
            if (i > one.get(one.size() - 1)) {
                ArrayList<Integer> temp = new ArrayList<Integer>();
                temp.addAll(one);
                temp.add(i);
                result.add(temp);
            }
        }
    }
    getIndexSublist(numbers, length, result);
}