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:Main.java

private static <T> void addCombination(List<List<T>> perms, List<Collection<T>> domains, int i) {

    if (i < domains.size()) {

        for (int permIndex = 0; permIndex < perms.size();) {

            List<T> perm = perms.get(permIndex);

            perms.remove(permIndex);

            if (domains.get(i).isEmpty()) {

                perms.clear();/*  w  w  w  .ja  va  2  s. c  o m*/
                return;
            }

            for (T domValue : domains.get(i)) {

                List<T> newPerm = new ArrayList<T>(perm);

                newPerm.add(domValue);
                perms.add(permIndex++, newPerm);
            }
        }

        addCombination(perms, domains, i + 1);
    }
}

From source file:com.kdmanalytics.toif.util.MemberUtil.java

/**
 * find suitable resources//from  w w  w . ja v a2 s.  c o  m
 * 
 * @param member
 * @param file
 * @return
 * @throws CoreException
 */
public static IResource findMembers(IResource member, IFileGroup file) throws CoreException {
    String name = file.getName();

    String path = file.getPath();
    path = path.replace("\\", "/");

    String[] pathArray = path.split("/");
    ArrayUtils.reverse(pathArray);

    List<IResource> result = new ArrayList<IResource>();
    List<IResource> toDo = new ArrayList<IResource>();

    toDo.add(member);

    while (!toDo.isEmpty()) {
        IResource resource = toDo.remove(0);

        if (resource instanceof IContainer) {
            for (IResource iResource : ((IContainer) resource).members()) {
                toDo.add(iResource);
            }
        }

        result.add(resource);

    }

    ResourceMatch match = new ResourceMatch();

    for (IResource iResource : result) {
        if (iResource == null) {
            continue;
        }
        if (iResource.getName().equals(name)) {
            IPath ipath = iResource.getLocation();

            String stringPath = ipath.toString();
            stringPath = stringPath.replace("\\", "/");

            String[] resourcePathArray = stringPath.split("/");
            ArrayUtils.reverse(resourcePathArray);

            int smallestSize = (pathArray.length < resourcePathArray.length) ? pathArray.length
                    : resourcePathArray.length;
            for (int i = 0; i < smallestSize; i++) {
                if (pathArray[i].equals(resourcePathArray[i])) {
                    if (i >= match.getScore()) {
                        match = new ResourceMatch(iResource, i);
                    }
                } else {
                    break;
                }

            }
        }
    }

    return match.getIResource();
}

From source file:ch.devmine.javaparser.utils.ParserUtils.java

public static List<String> prepareComments(String comment) {
    List<String> javadoc = new ArrayList<>(Arrays.asList(comment.split("\n")));
    if (javadoc.get(0).trim().isEmpty()) {
        javadoc.remove(0);
    }//from   www .  j  a v  a2 s  .  com
    if (!javadoc.isEmpty() && javadoc.get(javadoc.size() - 1).trim().isEmpty()) {
        javadoc.remove(javadoc.size() - 1);
    }
    for (int i = 0; i < javadoc.size() - 1; i++) {
        String line = javadoc.get(i);
        line = StringUtils.stripStart(line, "\t *");
        javadoc.set(i, line);
        if (!line.isEmpty()) {
            break;
        } else {
            javadoc.remove(line);
            i--;
        }
    }
    for (int j = javadoc.size() - 1; j >= 0; j--) {
        String line = javadoc.get(j);
        line = StringUtils.stripStart(line, "\t *");
        javadoc.set(j, line);
        if (!line.isEmpty()) {
            break;
        } else {
            javadoc.remove(line);
        }
    }
    for (int k = 0; k < javadoc.size() - 1; k++) {
        String line = javadoc.get(k);
        line = StringUtils.stripStart(line, "\t *");
        javadoc.set(k, line);
    }
    return javadoc;
}

From source file:com.kdmanalytics.toif.report.internal.util.MemberUtil.java

/**
 * find suitable resources/*from  w  w  w  .ja va2  s .  c  o m*/
 * 
 * @param member
 * @param file
 * @return
 * @throws CoreException
 */
public static IResource findMembers(IResource member, IFileGroup file) throws CoreException {
    String name = file.getName();

    String path = file.getPath();
    path = path.replace("\\", "/");

    String[] pathArray = path.split("/");
    ArrayUtils.reverse(pathArray);

    List<IResource> result = new ArrayList<IResource>();
    List<IResource> toDo = new ArrayList<IResource>();

    toDo.add(member);

    while (!toDo.isEmpty()) {
        IResource resource = toDo.remove(0);

        if (resource instanceof IContainer) {
            for (IResource iResource : ((IContainer) resource).members()) {
                toDo.add(iResource);
            }
        }

        result.add(resource);

    }

    ResourceMatch match = new ResourceMatch();

    for (IResource iResource : result) {
        if (iResource == null) {
            continue;
        }
        if (iResource.getName().equals(name)) {
            IPath ipath = iResource.getLocation();

            String stringPath = ipath.toString();
            stringPath = stringPath.replace("\\", "/");

            String[] resourcePathArray = stringPath.split("/");
            ArrayUtils.reverse(resourcePathArray);

            int smallestSize = (pathArray.length < resourcePathArray.length) ? pathArray.length
                    : resourcePathArray.length;
            for (int i = 0; i < smallestSize; i++) {
                if (pathArray[i].equals(resourcePathArray[i])) {
                    if (i >= match.getScore()) {
                        match = new ResourceMatch(iResource, i);
                        System.err.println(stringPath);
                    }
                } else {
                    break;
                }

            }
        }
    }

    return match.getIResource();
}

From source file:com.siemens.sw360.datahandler.common.ImportCSV.java

/**
 * reads a CSV file and returns its content as a list of CSVRecord
 *
 * @param in//w w  w.j av  a 2s . c om
 * @return list of records
 */
public static List<CSVRecord> readAsCSVRecords(InputStream in) {
    List<CSVRecord> records = null;

    try (Reader reader = new InputStreamReader(in)) {
        CSVParser parser = new CSVParser(reader, CommonUtils.sw360CsvFormat);
        records = parser.getRecords();
        records.remove(0); // Remove header
    } catch (IOException e) {
        log.error("Error parsing CSV File!", e);
    }

    // To avoid returning null above
    if (records == null)
        records = Collections.emptyList();

    return records;
}

From source file:Main.java

/**
 * //from   w ww. ja  v a  2s.  co  m
 * @param list
 * @return true : trim some null obj
 */
public static boolean trimList(List list) {
    if (isEmpty(list)) {
        return false;
    } else {
        int length = list.size();
        for (int i = length - 1; i >= 0; i--) {
            Object obj = list.get(i);
            if (obj == null) {
                list.remove(obj);
            }
        }
        return length != list.size();
    }
}

From source file:Main.java

private static List<String> filterParamNamesWithObjectValue(Map<String, Object> paramValueMap,
        List<String> ignoreParamNameList) {
    List<String> filteredParamNames = new ArrayList<>(paramValueMap.size());
    filteredParamNames.addAll(paramValueMap.keySet());
    if (ignoreParamNameList != null && ignoreParamNameList.size() > 0) {
        for (String ignoreParamName : ignoreParamNameList) {
            filteredParamNames.remove(ignoreParamName);
        }/* www .  jav a2 s.  c  om*/
    }
    return filteredParamNames;
}

From source file:com.izforge.izpack.panels.target.TargetPanelHelper.java

/**
 * Returns the installation path for the specified platform name.
 * <p/>//from  www  .  ja  v a  2s  . com
 * This looks for a variable named {@code TargetPanel.dir.<platform name>}. If none is found, it searches the
 * parent platforms, in a breadth-first manner.
 *
 * @param installData the installation data
 * @param name        the platform name
 * @return the default path, or {@code null} if none is found
 */
private static String getTargetPanelDir(InstallData installData, Platform.Name name) {
    String path = null;
    List<Platform.Name> queue = new ArrayList<Platform.Name>();
    queue.add(name);
    while (!queue.isEmpty()) {
        name = queue.remove(0);
        path = installData.getVariable(PREFIX + name.toString().toLowerCase());
        if (path != null) {
            break;
        }
        Collections.addAll(queue, name.getParents());
    }
    return path;
}

From source file:info.ajaxplorer.client.http.AjxpHttpClient.java

public static List<Cookie> getCookies(URI uri) {
    // Duplicate and prune
    List<Cookie> originalCookies = cookieStore.getCookies();
    List<Cookie> cookies = new ArrayList<Cookie>(originalCookies);
    for (int i = 0; i < originalCookies.size(); i++) {
        if (!originalCookies.get(i).getDomain().equals(uri.getHost())) {
            cookies.remove(originalCookies.get(i));
        }/*  w w  w.j a  v a  2s. c o  m*/
    }
    return cookies;
}

From source file:Main.java

private static List<String> filterParamNames(Map<String, Object> paramValueMap,
        List<String> ignoreParamNameList) {
    List<String> filteredParamNames = new ArrayList<>(paramValueMap.size());
    filteredParamNames.addAll(paramValueMap.keySet());
    if (ignoreParamNameList != null && ignoreParamNameList.size() > 0) {
        for (String ignoreParamName : ignoreParamNameList) {
            filteredParamNames.remove(ignoreParamName);
        }// w  w w.java 2s  . c o m
    }
    return filteredParamNames;
}