Example usage for java.util Set remove

List of usage examples for java.util Set remove

Introduction

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

Prototype

boolean remove(Object o);

Source Link

Document

Removes the specified element from this set if it is present (optional operation).

Usage

From source file:com.gargoylesoftware.htmlunit.runners.TestCaseCorrector.java

private static void removeNotYetImplemented(final List<String> lines, final int i, final String browserString) {
    final String previous = lines.get(i - 1);
    if (previous.contains("@NotYetImplemented")) {
        if (previous.indexOf('(') != -1) {
            final int p0 = previous.indexOf('(') + 1;
            final int p1 = previous.lastIndexOf(')');
            String browsers = previous.substring(p0, p1);
            if (browsers.indexOf('{') != -1) {
                browsers = browsers.substring(1, browsers.length() - 1).trim();
            }/* ww  w .ja  v a 2 s .  c om*/
            final Set<String> browserSet = new HashSet<>();
            for (final String browser : browsers.split(",")) {
                browserSet.add(browser.trim());
            }
            browserSet.remove(browserString);
            if (browserSet.size() == 1) {
                lines.set(i - 1, "    @NotYetImplemented(" + browserSet.iterator().next() + ")");
            } else if (browserSet.size() > 1) {
                lines.set(i - 1, "    @NotYetImplemented({ " + StringUtils.join(browserSet, ", ") + " })");
            } else {
                lines.remove(i - 1);
            }
        } else {
            final List<String> allBrowsers = new ArrayList<>(
                    Arrays.asList("CHROME", "IE11", "FF31", "FF38", "EDGE"));
            for (final Iterator<String> it = allBrowsers.iterator(); it.hasNext();) {
                if (it.next().equals(browserString)) {
                    it.remove();
                }
            }
            lines.set(i - 1, "    @NotYetImplemented({ " + StringUtils.join(allBrowsers, ", ") + " })");
        }
    }
}

From source file:com.silverpeas.util.MapUtil.java

/**
 * Centralizes the map removing that containing set collections
 *
 * @param <K>/*from   w  w w  .j  av  a  2s.  co m*/
 * @param <V>
 * @param map
 * @param key
 * @param value
 * @return
 */
public static <K, V> Set<V> removeValueSet(final Map<K, Set<V>> map, final K key, final V value) {

    Set<V> result = null;
    if (map != null) {

        // Old value
        result = map.get(key);
        if (result != null) {
            result.remove(value);
        }
    }

    // map result
    return result;
}

From source file:edu.memphis.ccrg.lida.proceduralmemory.ProceduralMemoryImpl.java

private static void removeFromMap(Scheme s, Collection<Condition> conditions, Map<Object, Set<Scheme>> map) {
    for (Condition c : conditions) {
        Set<Scheme> schemes = map.get(c.getConditionId());
        if (schemes != null) {
            schemes.remove(s);
        }/*from  w  ww .ja  v  a 2 s . c  o  m*/
    }
}

From source file:com.gargoylesoftware.htmlunit.general.HostExtractor.java

private static void ensure(final File file, final Set<String> set) throws IOException {
    final Set<String> unusedNames = new HashSet<>(set);
    final List<String> lines = FileUtils.readLines(file);
    for (final String line : lines) {
        for (final Iterator<String> it = unusedNames.iterator(); it.hasNext();) {
            if (line.contains("(\"" + it.next() + "\")")) {
                it.remove();/*from   ww  w  .ja v a  2 s. c  om*/
            }
        }
    }
    unusedNames.remove("this");
    unusedNames.remove("Boolean");
    unusedNames.remove("null");

    if (!unusedNames.isEmpty()) {
        for (final String name : unusedNames) {
            if (name.contains(" ")) {
                continue;
            }
            System.out.println("");
            System.out.println("    /**");
            System.out.println("     * @throws Exception if the test fails");
            System.out.println("     */");
            System.out.println("    @Test");
            System.out.println("    @Alerts(\"exception\")");
            String methodName = name;
            for (final String prefix : PREFIXES_) {
                if (methodName.startsWith(prefix)) {
                    methodName = prefix.toLowerCase(Locale.ROOT) + methodName.substring(prefix.length());
                    break;
                }
            }
            if (Character.isUpperCase(methodName.charAt(0))) {
                methodName = Character.toLowerCase(methodName.charAt(0)) + methodName.substring(1);
            }
            methodName = methodName.replace(".", "_");
            System.out.println("    public void " + methodName + "() throws Exception {");
            System.out.println("        test(\"" + name + "\");");
            System.out.println("    }");
        }
    }
    for (final String name : unusedNames) {
        if (name.contains(" ")) {
            System.out.println("Ignoring: " + name);
        }
    }
}

From source file:net.sf.morph.util.ContainerUtils.java

/**
 * Returns the intersection of multiple arrays as an array.  Implementation is O(n<sup>3</sup>).
 *
 * @param arrays//from   ww w. java  2 s  .com
 *            a List of arrays
 * @param componentType
 *            the runtime type of the returned array
 * @return the intersection of the arrays
 */
public static Object[] intersection(List arrays, Class componentType) {
    if (componentType == null) {
        throw new IllegalArgumentException("componentType must be speciifed");
    }
    if (arrays == null) {
        return null;
    }

    Set intersectionSet = new HashSet();
    intersectionSet.addAll(Arrays.asList(((Object[]) arrays.get(0))));
    for (int i = 1; i < arrays.size(); i++) {
        Object[] array = (Object[]) arrays.get(i);
        for (int j = 0; j < array.length; j++) {
            if (!contains(intersectionSet, array[j])) {
                intersectionSet.remove(array[j]);
            }
        }
    }

    Object[] intersectionArray = (Object[]) ClassUtils.createArray(componentType, intersectionSet.size());
    return intersectionSet.toArray(intersectionArray);
}

From source file:com.infovity.iep.loader.util.SupplierLoaderUtil.java

public static int getUniqueNumber(Set<Integer> set) {
    Integer n = null;//from  w  w w . j  a  va  2 s . c  om
    Iterator itr = set.iterator();
    while (itr.hasNext()) {
        n = (Integer) itr.next();
    }
    set.remove(n);
    return n;
}

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

/**
 * Build a data set that will be shown./*from   www  .j a v  a  2  s . com*/
 * 
 * @param lastAction
 *            the last build action
 * @return the data set
 */
private static CategoryDataset buildDataset(TodosBuildAction lastAction) {
    DataSetBuilder<String, NumberOnlyBuildLabel> builder = new DataSetBuilder<String, NumberOnlyBuildLabel>();

    List<TodosBuildAction> allValidActions = new LinkedList<TodosBuildAction>();
    Set<String> allPatterns = new HashSet<String>();

    getActionsAndPatterns(lastAction, allValidActions, allPatterns);

    for (TodosBuildAction action : allValidActions) {
        Set<String> remainingPatterns = new HashSet<String>(allPatterns);
        NumberOnlyBuildLabel buildLabel = new NumberOnlyBuildLabel(action.getBuild());

        for (TodosPatternStatistics statistics : action.getStatistics().getPatternStatistics()) {
            builder.add(statistics.getNumOccurrences(), statistics.getPattern(), buildLabel);
            remainingPatterns.remove(statistics.getPattern());
        }

        for (String pattern : remainingPatterns) {
            builder.add(0, pattern, buildLabel);
        }
    }

    return builder.build();
}

From source file:com.alibaba.jstorm.ui.UIUtils.java

public static void checkKey(List<String> ret, Set<String> temp, String key) {
    if (temp.contains(key)) {
        ret.add(key);//  w  w  w. ja  v  a 2s. c  om
        temp.remove(key);
    }
    return;
}

From source file:Main.java

public static Set<Class<?>> getMinimalImplementedInterfaceNames(Class<?> klass) {
    Set<Class<?>> interfaces = new HashSet<Class<?>>();
    while (klass != null) {
        Class<?>[] localInterfaces = klass.getInterfaces();
        for (Class<?> intf : localInterfaces) {
            boolean subsumed = false;
            for (Class<?> i : new ArrayList<Class<?>>(interfaces)) {
                if (intf.isAssignableFrom(i)) {
                    subsumed = true;//from  w  w w .  j ava  2s.  c om
                    break;
                } else if (i.isAssignableFrom(intf)) {
                    interfaces.remove(i);
                }
            }
            if (subsumed) {
                continue;
            }
            interfaces.add(intf);
        }
        klass = klass.getSuperclass();
    }
    return interfaces;
}

From source file:de.unisb.cs.st.javalanche.mutation.util.AddOffutt96Sufficient.java

private static Set<Integer> getReplacments(int operator, int standardReplaceOperator, int[] replaceOperators) {
    Set<Integer> result = new HashSet<Integer>();
    for (int i : replaceOperators) {
        result.add(i);/*from   w w  w  .  j  a va2 s .  c o m*/
    }
    result.remove(operator);
    result.remove(standardReplaceOperator);
    return result;
}