Example usage for java.util ArrayList remove

List of usage examples for java.util ArrayList remove

Introduction

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

Prototype

public boolean remove(Object o) 

Source Link

Document

Removes the first occurrence of the specified element from this list, if it is present.

Usage

From source file:edu.oregonstate.eecs.mcplan.domains.spbj.SpBjAction.java

@Override
public void undoAction(final SpBjState s) {
    assert (done);

    if (terminal) {
        uncompleteDealerHand(s);//  w  w  w. j av  a2s .co m
        terminal = false;
    }

    for (int i = cat.length - 1; i >= 0; --i) {
        final SpBjHand h = s.player_hand;
        final ArrayList<Card> cards = h.hands.get(i);
        switch (cat[i]) {
        case Hit: {
            final Card c = cards.remove(cards.size() - 1);
            s.deck().undeal(c);
            h.passed[i] = false;
            break;
        }
        case Pass:
            h.passed[i] = false;
            break;
        case Split: {
            final int j = h.children[i];
            final ArrayList<Card> child = h.hands.get(j);
            assert (child.size() == 2);
            assert (cards.size() == 2);
            s.deck().undeal(child.remove(child.size() - 1));
            s.deck().undeal(cards.remove(cards.size() - 1));
            cards.add(child.remove(0));
            h.Nhands -= 1;
            h.children[i] = 0;
            h.bets[j] = 0;
            h.passed[j] = true;
            h.hands.remove(h.hands.size() - 1);
            break;
        }
        case Double: {
            h.bets[i] /= 2;
            final Card c = cards.remove(cards.size() - 1);
            s.deck().undeal(c);
            h.passed[i] = false;
            break;
        }
        }
    }

    done = false;
}

From source file:com.icesoft.applications.faces.auctionMonitor.beans.LogBean.java

/**
 * Convenience method to clear a passed ArrayList Basically clones the
 * functionality of a Vector.removeAll/*from w  w  w .j  av  a2s.  c  om*/
 *
 * @param toClear to remove all elements from
 * @return ArrayList cleared (size = 0)
 */
private ArrayList clear(ArrayList toClear) {
    // Loop through the ArrayList and remove each element
    for (int i = 0, len = toClear.size(); i < len; i++) {
        toClear.remove(0);
    }

    return (toClear);
}

From source file:net.bpelunit.framework.ui.command.BPELUnitCommandLineRunner.java

@SuppressWarnings("unchecked")
private final void parseOptionsFromCommandLine(String[] args) {
    saveCoverageDetails = false;/*w  ww  .j  ava 2s.  c o  m*/

    CommandLineParser parser = new PosixParser();
    try {
        CommandLine cmd = parser.parse(options, args);

        verifyCommandLineArguments(cmd);

        verbose = cmd.hasOption(PARAMETER_VERBOSE);
        xmlFileName = trimEqualsSignFromStart(cmd.getOptionValue(PARAMETER_XMLFILE));
        logFileName = trimEqualsSignFromStart(cmd.getOptionValue(PARAMETER_LOGFILE));

        ArrayList<String> remainingOptions = new ArrayList<String>(cmd.getArgList());
        setAndValidateTestSuiteFileName(remainingOptions.remove(0));
        testCaseNames = remainingOptions;
    } catch (ParseException e) {
        showHelpAndExit();
    }
}

From source file:com.uwsoft.editor.data.manager.SceneDataManager.java

private void deleteScene(String sceneName) {
    ArrayList<SceneVO> scenes = dataManager.currentProjectInfoVO.scenes;
    SceneVO sceneToDelete = null;//  w w w.j av a  2 s .  co m
    for (SceneVO scene : scenes) {
        if (scene.sceneName.equals(sceneName)) {
            sceneToDelete = scene;
            break;
        }
    }
    if (sceneToDelete != null) {
        scenes.remove(sceneToDelete);
    }
    dataManager.currentProjectInfoVO.scenes = scenes;
    String projPath = dataManager.getCurrentWorkingPath() + "/" + dataManager.currentProjectVO.projectName;
    try {
        FileUtils.writeStringToFile(new File(projPath + "/project.dt"),
                dataManager.currentProjectInfoVO.constructJsonString(), "utf-8");
        FileUtils.forceDelete(new File(projPath + "/scenes/" + sceneName + ".dt"));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:administraScan.OrganizaDirectorios.java

public void copiarCompletos() throws IOException {
    FileUtils Files = new FileUtils();
    AdministraScan adm = new AdministraScan();
    File origen;/*from   w  ww  .java 2  s  . c  o m*/
    File destino;
    File f = new File(conf.carpetaCT);
    ArrayList<String> cts = new ArrayList<>(Arrays.asList(f.list()));
    for (String ct : cts) {
        String dirCT = conf.carpetaCT + ct.trim();
        File dir_expedientes = new File(dirCT);
        ArrayList<String> curps = new ArrayList<>(Arrays.asList(dir_expedientes.list()));
        for (String curp : curps) {
            String dircurp = dirCT + "\\" + curp.trim();
            File doc = new File(dircurp);
            ArrayList<String> documentos = new ArrayList<>(Arrays.asList(doc.list()));
            ArrayList<String> claves = adm.RetornaCT(documentos);
            ArrayList<String> obli_cedula = new ArrayList<>(Arrays.asList(conf.DOC_R));
            obli_cedula.remove("CUGE");
            boolean completo_cedula = claves.containsAll(obli_cedula)
                    && (claves.contains("CPL") || claves.contains("CPM") || claves.contains("CPD"))
                    && !claves.contains("CUGE");
            if (claves.containsAll(conf.OBLIGATORIOS) || completo_cedula) {
                String clave = "";
                String nombre_ss = "";
                clave = ct.substring(3, 5);
                this.conectarbd();
                String consultaDescripcionSS = "Select descripcion from cg_nivel_educativo where nivel_educativo = ?";
                try {
                    PreparedStatement SPreparada;
                    SPreparada = connection.prepareStatement(consultaDescripcionSS);
                    SPreparada.setString(1, clave);
                    ResultSet resultadoDescripcion = SPreparada.executeQuery();
                    if (resultadoDescripcion.next()) {
                        nombre_ss = resultadoDescripcion.getString("descripcion").trim();
                    }
                    SPreparada.close();
                    connection.close();

                } catch (SQLException ex) {
                    Logger.getLogger(OrganizaDirectorios.class.getName()).log(Level.SEVERE, null, ex);
                }
                String ruta_destino = conf.carpetaRemota + "completos\\" + nombre_ss + "\\" + ct.trim();
                origen = new File(dircurp);
                destino = new File(ruta_destino);
                File destino_final = new File(ruta_destino + "\\" + curp.trim());
                if (!destino_final.exists()) {
                    Files.copyDirectoryToDirectory(doc, destino);
                    System.out.println(
                            "Movi carpeta: " + doc.getAbsolutePath() + " a " + destino_final.getAbsolutePath());
                }
            }
        }
    }
}

From source file:com.moscona.dataSpace.ExportHelper.java

public void csvExport(DataFrame df, String fileName, boolean includeMetaData)
        throws FileNotFoundException, DataSpaceException {
    // FIXME exports sorted and label columns twice - once populated and once not - the populated ones are the wrong ones
    PrintStream out = new PrintStream(new File(fileName));
    try {/*w  w w.  j  av a2s . c om*/
        ArrayList<String> labels = new ArrayList<String>();
        ArrayList<String> sorted = new ArrayList<String>();

        for (String col : df.getColumnNames()) {
            if (df.isLabel(col)) {
                labels.add(col);
            }
            if (df.get(col).isSorted()) {
                sorted.add(col);
            }
        }

        if (includeMetaData) {
            csvOut(out, "name", df.getName());
            csvOut(out, "description", df.getDescription());
            csvOut(out, "row ID", df.getRowId());
            csvOut(out, "sort column", df.getSortColumn());

            Collections.sort(labels);
            Collections.sort(sorted);

            out.println(excelQuote("label columns") + "," + StringUtils.join(labels, ","));
            out.println(excelQuote("sorted columns") + "," + StringUtils.join(sorted, ","));
            out.println();
        }

        ArrayList<String> columns = new ArrayList<String>();
        ArrayList<String> remaining = new ArrayList<String>(df.getColumnNames());
        if (df.getRowId() != null) {
            // make first column the row ID
            String rowId = df.getRowId();
            columns.add(rowId);
            remaining.remove(rowId);
        }
        // add all the sorted columns
        columns.addAll(sorted);
        remaining.removeAll(sorted);
        remaining.removeAll(labels); // those will come in last
        Collections.sort(remaining);
        columns.addAll(remaining);
        columns.addAll(labels);

        out.println(StringUtils.join(columns, ","));
        IVectorIterator<Map<String, IScalar>> iterator = df.iterator();
        while (iterator.hasNext()) {
            Map<String, IScalar> row = iterator.next();
            ArrayList<String> values = new ArrayList<String>();
            for (String col : columns) {
                values.add(toCsvString(row.get(col)));
            }
            out.println(StringUtils.join(values, ","));
        }
    } finally {
        out.close();
    }
}

From source file:com.uwsoft.editor.proxy.SceneDataManager.java

private void deleteScene(String sceneName) {
    ProjectManager projectManager = facade.retrieveProxy(ProjectManager.NAME);
    ArrayList<SceneVO> scenes = projectManager.currentProjectInfoVO.scenes;
    SceneVO sceneToDelete = null;//from   w w  w. j ava 2 s.co m
    for (SceneVO scene : scenes) {
        if (scene.sceneName.equals(sceneName)) {
            sceneToDelete = scene;
            break;
        }
    }
    if (sceneToDelete != null) {
        scenes.remove(sceneToDelete);
    }
    projectManager.currentProjectInfoVO.scenes = scenes;
    String projPath = projectManager.getCurrentProjectPath();
    try {
        FileUtils.writeStringToFile(new File(projPath + "/project.dt"),
                projectManager.currentProjectInfoVO.constructJsonString(), "utf-8");
        FileUtils.forceDelete(new File(projPath + "/scenes/" + sceneName + ".dt"));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static int[] parseIntegerList(String list, int minValue, int maxValue) {
    ArrayList tmpList = new ArrayList();
    Pattern p = Pattern.compile("(\\d*)-(\\d*)");
    String[] a = list.replace(',', ' ').split("\\s+");
    int i = a.length;

    for (int i$ = 0; i$ < i; ++i$) {
        String token = a[i$];/*from   www.j a v  a  2s .  c  o m*/

        try {
            if (token.matches("\\d+")) {
                tmpList.add(Integer.valueOf(Integer.parseInt(token)));
            } else {
                Matcher e = p.matcher(token);

                if (e.matches()) {
                    String a1 = e.group(1);
                    String b = e.group(2);
                    int min = a1.equals("") ? minValue : Integer.parseInt(a1);
                    int max = b.equals("") ? maxValue : Integer.parseInt(b);

                    for (int i1 = min; i1 <= max; ++i1) {
                        tmpList.add(Integer.valueOf(i1));
                    }
                }
            }
        } catch (NumberFormatException var15) {
            ;
        }
    }

    if (minValue <= maxValue) {
        int var16 = 0;

        while (var16 < tmpList.size()) {
            if (((Integer) tmpList.get(var16)).intValue() >= minValue
                    && ((Integer) tmpList.get(var16)).intValue() <= maxValue) {
                ++var16;
            } else {
                tmpList.remove(var16);
            }
        }
    }

    int[] var17 = new int[tmpList.size()];

    for (i = 0; i < var17.length; ++i) {
        var17[i] = ((Integer) tmpList.get(i)).intValue();
    }

    return var17;
}

From source file:com.actionbarsherlock.internal.view.menu.ActionMenu.java

public void removeGroup(int groupId) {
    final ArrayList<ActionMenuItem> items = mItems;
    int itemCount = items.size();
    int i = 0;//w  w  w . j av a2  s.c  o m
    while (i < itemCount) {
        if (items.get(i).getGroupId() == groupId) {
            items.remove(i);
            itemCount--;
        } else {
            i++;
        }
    }
}

From source file:com.almende.eve.agent.example.ChatAgent.java

/**
 * Remove an agent from connections list.
 *
 * @param url Url of a connected ChatAgent
 * @throws IOException Signals that an I/O exception has occurred.
 */// w  ww.j ava2s . c  om
public void removeConnection(@Name("url") final String url) throws IOException {
    final ArrayList<String> connections = getState().get("connections", new TypeUtil<ArrayList<String>>() {
    });
    if (connections != null) {
        connections.remove(url);
        getState().put("connections", connections);

        log(getUsername() + " disconnected from " + url);
        // trigger a "connected" event
        final ObjectNode params = JOM.createObjectNode();
        params.put("url", url);
        getEventsFactory().trigger("disconnected", params);
    }
}