Example usage for java.util List remove

List of usage examples for java.util List remove

Introduction

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

Prototype

E remove(int index);

Source Link

Document

Removes the element at the specified position in this list (optional operation).

Usage

From source file:com.clxcommunications.xms.api.TagsTest.java

@Property
public void canIterateOverTags(List<String> tags) throws Exception {
    for (String t : Tags.of(tags)) {
        assertThat(t, is(tags.remove(0)));
    }//  www  .j a v  a  2s .c  o m
}

From source file:br.com.projetotcc.controller.FuncionalidadeController.java

@RequestMapping("/editarfuncionalidade")
public ModelAndView editarFuncionalidade(HttpServletRequest request) {
    ModelAndView modelAndView = new ModelAndView("editarfuncionalidade");
    Funcionalidade func = funcDao.getFuncionalidade(Integer.parseInt(request.getParameter("id")));
    modelAndView.addObject("funcionalidade", func);
    List<Complexidade> complexidades = complexDao.list();
    complexidades.remove(func.getComplexidade());
    complexidades.add(0, func.getComplexidade());
    modelAndView.addObject("complexidades", complexidades);
    List<Projeto> projetos = projetoDao.list();
    projetos.remove(func.getProjeto());// w  ww.j  a va  2  s .  c om
    projetos.add(0, func.getProjeto());
    modelAndView.addObject("projetos", projetos);
    return modelAndView;
}

From source file:Bag.java

public void remove(Object key, Object value) {
    List values = getValues(key);
    if (values != null) {
        values.remove(value);
        if (values.isEmpty()) {
            remove(key);/*from  w  ww  . j a v a2s  . c  o m*/
        }
    }
}

From source file:com.github.rwhogg.git_vcr.review.php.PhpmdReviewTool.java

@Override
public List<String> getResults(File file) throws ReviewFailedException {
    // delete the cache first
    Path pathToCache = FileSystems.getDefault().getPath(System.getProperty("user.home"), ".pdepend");
    try {/*from w  w  w. j  av a2 s .c  om*/
        FileUtils.deleteQuietly(pathToCache.toFile());
    } catch (Exception e) {
    }

    List<Object> rules = configuration.getList("rules");
    String commandTemplate = "\"%s\" text \"%s\"";
    List<String> results;
    try {
        StringBuffer ruleStringBuffer = new StringBuffer();
        for (Object rule : rules) {
            ruleStringBuffer.append((String) rule + ",");
        }
        String ruleString = ruleStringBuffer.toString();
        results = runProcess(String.format(commandTemplate, file.getAbsolutePath(),
                ruleString.substring(0, ruleString.length() - 1)));
    } catch (IOException e) {
        throw new ReviewFailedException(e.getLocalizedMessage(), this, file.getAbsolutePath());
    }

    // first result is always an empty line
    if ((results != null) && (results.size() > 0)) {
        List<String> copy = new LinkedList<>();
        copy.addAll(results);
        copy.remove(0);
        results = copy;
    }
    return results;
}

From source file:br.com.projetotcc.controller.EstimativaController.java

@RequestMapping("/editarestimativa")
public ModelAndView editarFuncionalidade(HttpServletRequest request) {
    ModelAndView modelAndView = new ModelAndView("editarestimativa");
    Estimativa est = estDao.getEstimativa(Integer.parseInt(request.getParameter("id")));
    modelAndView.addObject("estimativa", est);
    List<Funcionalidade> funcs = funcDao.list();
    funcs.remove(est.getFunc());
    funcs.add(0, est.getFunc());/*from  w ww  .  j  a v a  2  s  .c o m*/
    modelAndView.addObject("funcionalidades", funcs);
    List<Desenvolvedor> desenvolvedores = desenvolvedorDao.list();
    desenvolvedores.remove(est.getDesenvolvedor());
    desenvolvedores.add(0, est.getDesenvolvedor());
    modelAndView.addObject("desenvolvedores", desenvolvedores);
    return modelAndView;
}

From source file:dicky.controlleruser.CartController.java

@RequestMapping(value = "delete/{index}", method = RequestMethod.GET)
public String delete(@PathVariable("index") int index, HttpSession session) {
    List<Item> cart = (List<Item>) session.getAttribute("cart");
    cart.remove(index);
    session.setAttribute("cart", cart);
    return "redirect:/cart.html";
}

From source file:Main.java

public static void doMergeSort(List<Integer> list1, int start1, int end1, int start2, int end2) {

    int[] temp = new int[list1.size()];
    int k = 0, i = start1;
    while (start1 <= end1 && start2 <= end2) {
        if (list1.get(start1) == list1.get(start2)) {
            temp[k] = list1.get(start1);
            k++;//from ww w  .  ja  v  a  2  s. c  o m
            start1++;
            temp[k] = list1.get(start2);
            k++;
            start2++;
        } else if (list1.get(start1) > list1.get(start2)) {
            temp[k] = list1.get(start1);
            k++;
            start1++;
        } else if (list1.get(start1) < list1.get(start2)) {
            temp[k] = list1.get(start2);
            k++;
            start2++;
        }
    }
    if (start1 <= end1) {
        for (; start1 <= end1; start1++, k++) {
            temp[k] = list1.get(start1);
        }
    }
    if (start2 <= end2) {
        for (; start2 <= end2; start2++)
            temp[k] = list1.get(start2);
    }
    for (int m = 0; m < k; m++, i++) {
        list1.remove(i);
        list1.add(i, temp[m]);
    }
}

From source file:it.unibas.spicy.utility.GenericListGenerator.java

@SuppressWarnings("unchecked")
private List<List<T>> rest(List<List<T>> list) {
    if (list.size() == 0) {
        throw new IllegalArgumentException("Empty list does not have rest");
    }//from w  w w.j a va  2 s . com
    List<List<T>> clone = (List<List<T>>) ((ArrayList<List<T>>) list).clone();
    clone.remove(0);
    return clone;
}

From source file:com.google.mr4c.sources.LogsDatasetSource.java

public synchronized void copyToFinal() throws IOException {
    List<String> names = new ArrayList<String>(m_fileSrc.getAllFileNames());
    names.remove(ZIP_FILE_NAME);
    DataFileSink zipSink = m_fileSrc.getFileSink(ZIP_FILE_NAME);
    OutputStream output = zipSink.getFileOutputStream();
    try {/*from w ww .j  a  v a  2 s  .c  o m*/
        ZipOutputStream zipStream = new ZipOutputStream(output);
        for (String name : names) {
            addZipEntry(zipStream, name);
        }
        zipStream.finish();
    } finally {
        output.close();
    }
}

From source file:com.googlecode.jsonschema2pojo.FragmentResolver.java

private JsonNode resolve(JsonNode tree, List<String> path) {

    if (path.isEmpty()) {
        return tree;
    } else {//from  w  w w.j av  a2  s  .co m
        String part = path.remove(0);

        if (tree.isArray()) {
            try {
                int index = Integer.parseInt(part);
                return resolve(tree.get(index), path);
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException("Not a valid array index: " + part);
            }
        }

        if (tree.has(part)) {
            return resolve(tree.get(part), path);
        } else {
            throw new IllegalArgumentException("Path not present: " + part);
        }
    }

}