Example usage for java.util ArrayList clear

List of usage examples for java.util ArrayList clear

Introduction

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

Prototype

public void clear() 

Source Link

Document

Removes all of the elements from this list.

Usage

From source file:Main.java

public static void getTop(float[] array, ArrayList<Integer> rankList, int i) {
    rankList.clear();

    int index = 0;
    HashSet<Integer> scanned = new HashSet<Integer>();
    float max = Float.MIN_VALUE;
    for (int m = 0; m < i && m < array.length; m++) {
        boolean flag = false;
        max = Float.MIN_VALUE;/*w  w w.jav a  2s.c  o m*/
        for (int no = 0; no < array.length; no++) {
            if (!scanned.contains(no) && array[no] >= max) {
                index = no;
                max = array[no];
                flag = true;
            }
        }
        if (flag) { // found value
            scanned.add(index);
            rankList.add(index);
        }
    }
}

From source file:Main.java

public static void getTop(float[] array, ArrayList<Integer> rankList, int i) {
    rankList.clear();

    int index = 0;
    HashSet<Integer> scanned = new HashSet<Integer>();
    float max = Float.MIN_VALUE;
    for (int m = 0; m < i && m < array.length; m++) {
        boolean flag = false;
        max = Float.MIN_VALUE;/*from www . ja  va  2 s.c  om*/
        for (int no = 0; no < array.length; no++) {
            if (!scanned.contains(no) && array[no] >= max) {
                index = no;
                max = array[no];
                flag = true;
            }
        }
        if (flag) { // found value
            scanned.add(index);
            rankList.add(index);
            // rankProbs.add(array[index]);
        }
        // System.out.println(m + "\t" + index);
    }
}

From source file:Main.java

public static void getTop(float[] array, ArrayList<Integer> rankList, ArrayList<Float> rankProbs, int i) {
    // clear/*from   w w  w  .jav a 2  s  . com*/
    rankList.clear();
    rankProbs.clear();
    //
    int index = 0;
    HashSet<Integer> scanned = new HashSet<Integer>();
    float max = Float.MIN_VALUE;
    for (int m = 0; m < i && m < array.length; m++) {
        boolean flag = false;
        max = Float.MIN_VALUE;
        for (int no = 0; no < array.length; no++) {
            if (array[no] >= max && !scanned.contains(no)) {
                index = no;
                max = array[no];
                flag = true;
            }
        }
        if (flag) { // found value
            scanned.add(index);
            rankList.add(index);
            rankProbs.add(array[index]);
        }
        // System.out.println(m + "\t" + index);
    }
}

From source file:Main.java

public static void getTop(float[] array, ArrayList<Integer> rankList, ArrayList<Float> rankProbs, int i) {
    // clear/* ww  w.j  av  a  2  s  .c  om*/
    rankList.clear();
    rankProbs.clear();
    //
    int index = 0;
    int count = 0;
    HashSet<Integer> scanned = new HashSet<Integer>();
    float max = Float.MIN_VALUE;
    for (int m = 0; m < i && m < array.length; m++) {
        boolean flag = false;
        max = Float.MIN_VALUE;
        for (int no = 0; no < array.length; no++) {
            if (array[no] >= max && !scanned.contains(no)) {
                index = no;
                max = array[no];
                flag = true;
            }
        }
        if (flag) { // found value
            scanned.add(index);
            rankList.add(index);
            rankProbs.add(array[index]);
        }
        //System.out.println(m + "\t" + index);
    }
}

From source file:Main.java

public static void split(String[] items, ArrayList<String> res, int number) {
    // split items to res1 and res2, where res2 has number items
    res.clear();
    String res1 = "";
    String res2 = "";
    ArrayList<String> newList = new ArrayList<String>();
    for (int i = 0; i < items.length; i++) {
        newList.add(items[i]);/* ww  w  .j a v  a  2 s. com*/
    }
    Collections.shuffle(newList);
    for (int i = 0; i < newList.size(); i++) {
        if (i < number) {
            res1 += newList.get(i) + "\t";
        } else {
            res2 += newList.get(i) + "\t";
        }
    }
    res.add(res1);
    res.add(res2);
}

From source file:Main.java

public static void getTopNZ(float[] array, int[] counts, ArrayList<Integer> rankList,
        ArrayList<Float> rankProbs, int i, int threshold) {
    // clear/* ww w . j av  a  2  s .co  m*/
    rankList.clear();
    rankProbs.clear();
    //
    int index = 0;
    float max = Float.MIN_VALUE;
    for (int m = 0; m < i && m < array.length; m++) {
        boolean flag = false;
        max = Float.MIN_VALUE;
        for (int no = 0; no < array.length; no++) {
            if (counts[no] >= threshold) {
                if (array[no] >= max && !rankList.contains(no)) {
                    index = no;
                    max = array[no];
                    flag = true;
                }
            }
        }
        if (flag) { // found value
            rankList.add(index);
            //            rankProbs.add(array[index]);
            rankProbs.add(counts[index] + 0.0f);
        }
        //System.out.println(m + "\t" + index);
    }
}

From source file:Main.java

public static void uniqe(ArrayList<String> queryDoc) {
    // add elements to al, including duplicates
    HashSet<String> hs = new HashSet<String>();
    hs.addAll(queryDoc);/*from  w  w w .  jav a2  s .co  m*/
    queryDoc.clear();
    queryDoc.addAll(hs);
}

From source file:Main.java

public static void uniqe(ArrayList<Integer> items) {
    // add elements to al, including duplicates
    HashSet<Integer> hs = new HashSet<Integer>();
    hs.addAll(items);//from  w ww  .  ja va2  s . c o m
    items.clear();
    items.addAll(hs);
}

From source file:automaticdatabaseupdate.FileHandler.java

private static ArrayList<String> ParseLogFile(String strRawString) {
    ArrayList<String> strList = new ArrayList<>();
    strList.clear();

    if (strRawString.matches(".*\\[.*\\].*")) {
        String[] tokens = strRawString.split("\\s*-\\s*");
        strList.add(tokens[0]);/*from  w  w w .  j av  a2 s.c o m*/
        strList.add(tokens[1]);
    } else {
        strList.add("");
        strList.add(strRawString);
    }

    return strList;
}

From source file:automaticdatabaseupdate.FileHandler.java

/**
 *
 * @param strRawString  - param to be tokenized
 * @return              - return string list of tokens
 *//*w ww  .j  a  v a2  s. c  om*/
private static ArrayList<String> ParseUpdateFile(String strRawString) {
    ArrayList<String> strList = new ArrayList<>();
    strList.clear();

    String[] tokens = strRawString.split("[\\^]"); /* old regex: "[\\^.\\^.]" */
    for (int i = 0; i < tokens.length; i++) {
        tokens[i] = tokens[i].replaceAll("~", "");
        if (tokens[i].equals(""))
            strList.add("0");
        else
            strList.add(tokens[i]);
    }

    return strList;
}