Example usage for java.util List clear

List of usage examples for java.util List clear

Introduction

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

Prototype

void clear();

Source Link

Document

Removes all of the elements from this list (optional operation).

Usage

From source file:Main.java

public static void reorder(List originalList, int perm[], List newList) {
    newList.clear();
    int len = originalList.size();
    int[] newPerm = new int[len];
    for (int i = 0; i < len; i++)
        newPerm[perm[i]] = i;/*from   w  w  w  . j  a va  2 s .com*/

    for (int i = 0; i < len; i++)
        newList.add(originalList.get(newPerm[i]));
}

From source file:Main.java

public static void copy(List<Integer> destList, List<Integer> srcList) {
    destList.clear();
    destList.addAll(srcList);/* w ww  .  jav a2 s.co m*/
}

From source file:Main.java

public static void clearList(List list) {
    if (list != null) {
        list.clear();
    }
    list = null;
}

From source file:Main.java

public static List removeDuplicate(List list) {
    HashSet h = new HashSet(list);
    list.clear();
    list.addAll(h);/*  w w  w.  ja va 2s. c om*/
    return list;
}

From source file:Main.java

public static <T> void slice(List<T> oldList, List<T> newList, int start, int len) {
    newList.clear();
    int end = start + len;
    for (int i = start; i < end; i++) {
        newList.add(oldList.get(i));/*from  w  w  w .j  a  v a 2  s.c om*/
    }
}

From source file:Main.java

public static void removeDuplicates(List list) {
    Set set = new LinkedHashSet(list);
    list.clear();
    list.addAll(set);/*from   www .j a v  a2 s.  co  m*/
}

From source file:Main.java

public static List<String> removeDuplicate(List<String> list) {
    HashSet<String> hashSet = new HashSet<String>(list);
    list.clear();
    list.addAll(hashSet);//from w  w w  . java  2 s  .  c o m
    return list;
}

From source file:com.mellanox.hadoop.mapred.UdaShuffleProviderPluginShared.java

static void buildCmdParams(List<String> params, JobConf jobConf) {
    params.clear();

    params.add("-w");
    params.add(jobConf.get("mapred.rdma.wqe.per.conn", "256"));
    params.add("-r");
    params.add(jobConf.get("mapred.rdma.cma.port", "9011"));
    params.add("-m");
    params.add("1");

    params.add("-g");
    params.add(System.getProperty("hadoop.log.dir"));

    params.add("-s");
    params.add(jobConf.get("mapred.rdma.buf.size", "1024"));
}

From source file:Main.java

public static void clearList(List... lists) {
    int length = lists.length;
    for (int i = 0; i < length; i++) {
        List l = lists[i];
        if (l == null) {
            continue;
        }/*from  w  ww .  j  ava  2 s .com*/
        l.clear();
        l = null;
    }
}

From source file:Main.java

public static <T> void clear(List<T> list) {
    if (list == null) {
        list = new ArrayList<T>();
    } else {//from w w  w  .  j  a  v  a  2s.c o m
        list.clear();
    }
}