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

/**
 * Assign or make new list from source list. Use ArrayList for new list.
 * //w w w. jav a  2s  . c o  m
 * @param src
 * @param dst
 * @return
 */
public static <T> List<T> instanceList(List<T> src, List<T> dst) {
    List<T> ret = null;
    if (src != null) {
        if (dst == null) {
            dst = new ArrayList<>();
        }

        dst.clear();
        dst.addAll(src);
        ret = dst;
    }

    return ret;
}

From source file:com.ignorelist.kassandra.steam.scraper.SharedConfig.java

private static void setTagsTagNode(VdfNode tagNode, Set<String> tags) {
    List<VdfAttribute> attributes = tagNode.getAttributes();
    attributes.clear();
    for (String tag : tags) {
        tagNode.addAttribute(Integer.toString(attributes.size()), tag);
    }//  w  ww  .j ava 2 s .  com
}

From source file:main.StratioENEI.java

private static float calculate(float[][] custos, int cidadeInicial, int cidadeFinal, List<String> ordem) {

    // System.out.printf("%d -> %d\n", cidadeInicial, cidadeFinal);
    ordem.clear();
    ordem.add(0, String.valueOf(cidadeInicial));
    ordem.add(1, String.valueOf(cidadeFinal));
    int i;/*from  w  w w. jav  a  2  s  .c o  m*/
    for (i = 0; i < custos.length; i++) {
        if (ordem.contains(String.valueOf(i))) {
            continue;
        }
        float minimo = Float.MAX_VALUE;
        int idxMin = 1;
        //   System.out.println(i);
        for (int j = 1; j < ordem.size(); j++) {
            //     System.out.printf(">%d|%d\n>>B4: %s\n",i, j, ordem);
            ordem.add(j, String.valueOf(i));
            //      System.out.printf(">>After: %s\n", ordem);
            float value = calcCost(ordem, custos);
            //  System.out.println("Value: "+value);
            ordem.remove(j);

            if (value < minimo) {
                minimo = value;
                idxMin = j;
            }
        }
        ordem.add(idxMin, String.valueOf(i));
        //    System.out.println(ordem);
    }
    return calcCost(ordem, custos);
}

From source file:Main.java

public static void clearTempFile(List<File> listTempFile, File skipfile) {
    listTempFile.remove(skipfile);/*from   w  ww  .  ja v  a2s  .  c o m*/
    for (File file : listTempFile) {
        if (file.exists()) {
            file.delete();
        }
    }
    listTempFile.clear();
}

From source file:edu.uci.ics.asterix.optimizer.rules.ByNameToByHandleFieldAccessRule.java

private static void byNameToByHandle(AssignOperator fieldAccessOp, IOptimizationContext context) {
    Mutable<ILogicalOperator> opUnder = fieldAccessOp.getInputs().get(0);
    AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) fieldAccessOp.getExpressions().get(0)
            .getValue();//  w  w  w .  j ava  2  s  . com
    ILogicalExpression a1 = fce.getArguments().get(0).getValue();

    VariableReferenceExpression x;
    if (a1.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
        x = (VariableReferenceExpression) a1;
    } else {
        LogicalVariable var1 = context.newVar();
        ArrayList<LogicalVariable> varArray = new ArrayList<LogicalVariable>(1);
        varArray.add(var1);
        ArrayList<Mutable<ILogicalExpression>> exprArray = new ArrayList<Mutable<ILogicalExpression>>(1);
        exprArray.add(new MutableObject<ILogicalExpression>(a1));
        AssignOperator assignVar = new AssignOperator(varArray, exprArray);
        x = new VariableReferenceExpression(var1);
        assignVar.getInputs().add(opUnder);
        opUnder = new MutableObject<ILogicalOperator>(assignVar);
    }

    // let $t := type-of(x)
    LogicalVariable t = context.newVar();

    AbstractFunctionCallExpression typeOf = new ScalarFunctionCallExpression(
            FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.TYPE_OF));
    typeOf.getArguments().add(new MutableObject<ILogicalExpression>(x));
    AssignOperator typAssign = new AssignOperator(t, new MutableObject<ILogicalExpression>(typeOf));
    typAssign.getInputs().add(opUnder);

    // let $w := get-handle($t, path-expression)
    LogicalVariable w = context.newVar();
    AbstractFunctionCallExpression getHandle = new ScalarFunctionCallExpression(
            FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.GET_HANDLE));
    getHandle.getArguments().add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(t)));
    // the accessed field
    getHandle.getArguments().add(new MutableObject<ILogicalExpression>(fce.getArguments().get(1).getValue()));
    AssignOperator handleAssign = new AssignOperator(w, new MutableObject<ILogicalExpression>(getHandle));
    handleAssign.getInputs().add(new MutableObject<ILogicalOperator>(typAssign));

    // let $y := get-data(x, $w)
    AbstractFunctionCallExpression getData = new ScalarFunctionCallExpression(
            FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.GET_DATA));
    VariableReferenceExpression ref2 = new VariableReferenceExpression(x.getVariableReference());
    getData.getArguments().add(new MutableObject<ILogicalExpression>(ref2));
    getData.getArguments().add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(w)));
    fieldAccessOp.getExpressions().get(0).setValue(getData);
    List<Mutable<ILogicalOperator>> faInputs = fieldAccessOp.getInputs();
    faInputs.clear();
    faInputs.add(new MutableObject<ILogicalOperator>(handleAssign));

    // fieldAccess.setAnnotation(OperatorAnnotation.FIELD_ACCESS,
    // fce.getArguments().get(0));
    fieldAccessOp.removeAnnotation(AsterixOperatorAnnotations.PUSHED_FIELD_ACCESS);
}

From source file:de.tynne.benchmarksuite.Main.java

private static void checkNano(PrintStream ps) {
    List<Long> diffs = new ArrayList<>();

    nanoNullLoop(1000000, diffs);// ww w  . ja  v  a 2 s .  c  o m
    diffs.clear();
    nanoNullLoop(1000000, diffs);

    LongSummaryStatistics statistics = diffs.stream().mapToLong(l -> l).summaryStatistics();

    ps.printf("min=%d, avg=%g, max=%d\n", statistics.getMin(), statistics.getAverage(), statistics.getMax());
}

From source file:org.jenkinsci.plugins.todos.TodosChartBuilder.java

/**
 * Get all valid actions and all patterns defined through all builds.
 * //from w w w  .  j a  v a 2  s .c o m
 * @param lastAction
 *            the last action
 * @param outAllValidActions
 *            all valid actions with statistics defined, output parameter
 * @param outAllPatterns
 *            all patterns defined through all builds
 */
private static void getActionsAndPatterns(TodosBuildAction lastAction,
        List<TodosBuildAction> outAllValidActions, Set<String> outAllPatterns) {
    outAllValidActions.clear();
    outAllPatterns.clear();

    TodosBuildAction action = lastAction;

    while (action != null) {
        if (action.getStatistics() != null) {
            for (TodosPatternStatistics statistics : action.getStatistics().getPatternStatistics()) {
                outAllPatterns.add(statistics.getPattern());
            }

            outAllValidActions.add(action);
        }

        action = action.getPreviousAction();
    }
}

From source file:edu.berkeley.nwbqueryengine.util.ValuesUtil.java

public static List<NwbResult> removeDuplicities(List<NwbResult> input) {
    List<NwbResult> al = new ArrayList<>(input);
    Set<NwbResult> hs = new HashSet<>();
    hs.addAll(al);/*w  w  w . j a  va2  s .  c o  m*/
    al.clear();
    al.addAll(hs);
    return al;
}

From source file:Main.java

/**
 * Safely free all {@link Bitmap} in a bitmap {@link List}.
 * //from ww w . ja v a 2 s.c  o m
 * @param bmpList
 *            Bitmap list.
 */
public final static void freeBitmapList(List<Bitmap> bmpList) {
    if (null != bmpList) {
        for (Bitmap bmp : bmpList) {
            if (null != bmp && !bmp.isRecycled()) {
                bmp.recycle();
            }
        }
        bmpList.clear();
    }
}

From source file:Main.java

public static void fillRightList(String[] pairsList, List<String> namesList, ArrayAdapter<String> adapter,
        String targetPair) {/*from w w  w .j av  a 2  s. c om*/
    String[] componentsList;
    String targetName = targetPair.split("-")[0];
    if (targetPair.length() != 0) {
        namesList.clear();
        for (String s : pairsList) {
            componentsList = s.split("-");
            if (componentsList[0].equals(targetName)) {
                namesList.add(componentsList[1]);
            }
        }
        if (adapter != null) {
            adapter.notifyDataSetChanged();
        }
    }
}