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:edu.uci.ics.hyracks.algebricks.core.algebra.util.OperatorPropertiesUtil.java

/**
 * Adds the free variables of the plan rooted at that operator to the
 * collection provided./*from   w w  w  .j  a  v  a  2 s  .c  o m*/
 * 
 * @param op
 * @param vars
 *            - The collection to which the free variables will be added.
 */
public static void getFreeVariablesInSelfOrDesc(AbstractLogicalOperator op, Set<LogicalVariable> freeVars)
        throws AlgebricksException {
    HashSet<LogicalVariable> produced = new HashSet<LogicalVariable>();
    VariableUtilities.getProducedVariables(op, produced);
    for (LogicalVariable v : produced) {
        freeVars.remove(v);
    }

    HashSet<LogicalVariable> used = new HashSet<LogicalVariable>();
    VariableUtilities.getUsedVariables(op, used);
    for (LogicalVariable v : used) {
        if (!freeVars.contains(v)) {
            freeVars.add(v);
        }
    }

    if (op.hasNestedPlans()) {
        AbstractOperatorWithNestedPlans s = (AbstractOperatorWithNestedPlans) op;
        for (ILogicalPlan p : s.getNestedPlans()) {
            for (Mutable<ILogicalOperator> r : p.getRoots()) {
                getFreeVariablesInSelfOrDesc((AbstractLogicalOperator) r.getValue(), freeVars);
            }
        }
        s.getUsedVariablesExceptNestedPlans(freeVars);
        HashSet<LogicalVariable> produced2 = new HashSet<LogicalVariable>();
        s.getProducedVariablesExceptNestedPlans(produced2);
        freeVars.removeAll(produced);
    }
    for (Mutable<ILogicalOperator> i : op.getInputs()) {
        getFreeVariablesInSelfOrDesc((AbstractLogicalOperator) i.getValue(), freeVars);
    }
}

From source file:ch.systemsx.cisd.openbis.generic.server.dataaccess.db.HibernateSearchDAOTest.java

private static Set<EntityPropertyPE> removeProperty(IEntityPropertiesHolder propertiesHolder,
        EntityPropertyPE property) {/*from  ww  w .j  a v a2s . c o  m*/
    Set<EntityPropertyPE> properties = getCopiedProperties(propertiesHolder);
    boolean removed = properties.remove(property);
    assert removed : "property could not be removed";
    propertiesHolder.setProperties(properties);
    return properties;
}

From source file:musite.ProteinsUtil.java

/**
 * /*from  w ww  . ja v a  2  s  . c  o  m*/
 * @param pro1
 * @param pro2
 * @param operationOnSites
 * @return
 */
public static Protein mergeProteins(final Protein pro1, final Protein pro2,
        final MergeOperation operationOnSites) {
    if (pro1 == null && pro2 == null)
        return null;

    if (pro2 == null) {
        Protein pro = new ProteinImpl(pro1);
        if (operationOnSites == MergeOperation.INTERSECTION) {
            ResidueAnnotationUtil.removeAnnotations(pro);
        }
        return pro;
    }

    if (pro1 == null) {
        Protein pro = new ProteinImpl(pro2);
        if (operationOnSites == MergeOperation.INTERSECTION || operationOnSites == MergeOperation.DIFFERENCE) {
            ResidueAnnotationUtil.removeAnnotations(pro);
        }
        return pro;
    }

    Protein pro = new ProteinImpl(pro1);
    //        ResidueAnnotationUtil.removeAnnotations(pro);
    //Protein pro = new ProteinImpl(pro1, musite.util.CollectionUtil
    //        .getSet(Protein.ACCESSION, Protein.SEQUENCE)); // common sites

    // merge sequence
    String seq = pro2.getSequence();
    if (seq != null) {
        String currSeq = pro.getSequence();
        if (currSeq == null) {
            pro.setSequence(seq);
        }
        //            else {
        //                if (!currSeq.equalsIgnoreCase(seq)) {
        //                    return pro2;
        //                }
        //            }
    }

    // merge residue annotations
    Set<String> anntypes = ResidueAnnotationUtil.getAnnotationTypes(pro2);
    if (anntypes != null) {
        for (String anntype : anntypes) {
            final MultiMap<Integer, Map<String, Object>> mm = ResidueAnnotationUtil.extractAnnotation(pro2,
                    anntype);
            if (operationOnSites == MergeOperation.UNION) {
                for (Map.Entry<Integer, Collection<Map<String, Object>>> entry : mm.entrySet()) {
                    int site = entry.getKey();
                    Collection<Map<String, Object>> current = ResidueAnnotationUtil.extractAnnotation(pro, site,
                            anntype);
                    for (Map<String, Object> m : entry.getValue()) {
                        if (current == null || !current.contains(m)) // remove redundant annotations
                            ResidueAnnotationUtil.annotate(pro, site, anntype, m);
                    }
                }
            } else {
                ResidueAnnotationUtil.removeAnnotations(pro, anntype,
                        new ResidueAnnotationUtil.AnnotationFilter() {
                            public boolean filter(int loc, Map<String, Object> annotation) {
                                Collection<Map<String, Object>> anns2 = mm.get(loc);
                                return (anns2 != null && anns2.contains(
                                        annotation)) == (operationOnSites == MergeOperation.DIFFERENCE);
                            }
                        });
            }
        }
    }

    Set<String> info = new HashSet<String>(pro2.getInfoMap().keySet());
    info.remove(ResidueAnnotationUtil.RESIDUE_ANNOTATION);
    pro.copyFrom(pro2, false, info); // copy all fields except RESIDUE_ANNOTATION without replacement

    return pro;
}

From source file:edu.uci.ics.hyracks.algebricks.core.algebra.util.OperatorPropertiesUtil.java

private static void getFreeVariablesInOp(ILogicalOperator op, Set<LogicalVariable> freeVars)
        throws AlgebricksException {
    VariableUtilities.getUsedVariables(op, freeVars);
    HashSet<LogicalVariable> produced = new HashSet<LogicalVariable>();
    VariableUtilities.getProducedVariables(op, produced);
    for (LogicalVariable v : produced) {
        freeVars.remove(v);
    }/* www. j  av a2s.  co m*/
}

From source file:com.joyent.manta.client.MantaObjectDepthComparatorTest.java

private static void assertOrdering(final List<MantaObject> sorted) {
    Set<String> parentDirs = new LinkedHashSet<>();
    int index = 0;

    for (MantaObject obj : sorted) {
        if (obj.isDirectory()) {
            String parentDir = Paths.get(obj.getPath()).getParent().toString();

            Assert.assertFalse(parentDirs.contains(parentDir),
                    "The parent of this directory was encountered before " + "this directory [index=" + index
                            + "].");

            parentDirs.remove(obj.getPath());
        } else {//from w w w.j  a  v  a2  s .  com
            String fileParentDir = Paths.get(obj.getPath()).getParent().toString();

            Assert.assertFalse(parentDirs.contains(fileParentDir),
                    "Parent directory path was returned before file path. " + "Index [" + index
                            + "] was out of order. " + "Actual sorting:\n" + StringUtils.join(sorted, "\n"));
        }

        index++;
    }
}

From source file:com.asakusafw.directio.hive.serde.DataModelDriver.java

private static List<Mapping> computeMappingByName(DataModelDescriptor target, StructObjectInspector source) {
    if (LOG.isDebugEnabled()) {
        LOG.debug(MessageFormat.format("Mapping columns by their name: model={0}", //$NON-NLS-1$
                target.getDataModelClass().getName()));
    }//  w  w w.  j a v a 2 s .  co m
    Set<PropertyDescriptor> rest = new LinkedHashSet<>(target.getPropertyDescriptors());
    List<Mapping> mappings = new ArrayList<>();
    for (StructField s : source.getAllStructFieldRefs()) {
        String name = s.getFieldName();
        PropertyDescriptor t = target.findPropertyDescriptor(name);
        if (t != null) {
            mappings.add(new Mapping(s, t));
            rest.remove(t);
        } else {
            mappings.add(new Mapping(s, null));
        }
    }
    for (PropertyDescriptor t : rest) {
        mappings.add(new Mapping(null, t));
    }
    return mappings;
}

From source file:de.micromata.genome.jpa.metainf.MetaInfoUtils.java

private static void addDepsFirst(EntityMetadata table, Set<EntityMetadata> remainsings,
        List<EntityMetadata> sortedTable) {
    if (remainsings.contains(table) == false) {
        return;/*from w  w w .ja  va2s .c om*/
    }
    remainsings.remove(table);
    for (EntityMetadata nt : table.getReferencedBy()) {
        addDepsFirst(nt, remainsings, sortedTable);
    }
    sortedTable.add(table);
}

From source file:com.streamsets.pipeline.lib.fuzzy.FuzzyMatch.java

private static Set<String> tokenizeString(String str) {
    Set<String> set = new HashSet<>();

    // Normalize and tokenize the input strings before storing as a set.
    StringTokenizer st = new StringTokenizer(str);
    while (st.hasMoreTokens()) {
        String t1 = st.nextToken();
        String[] tokens = camelAndSnakeCaseSplitter.split(t1);
        for (int i = 0; i < tokens.length; i++) {
            tokens[i] = tokens[i].toLowerCase();
        }/*w  ww.  j ava2  s  .com*/
        Collections.addAll(set, tokens);
    }

    set.remove("");

    return set;
}

From source file:org.jboss.as.test.integration.logging.formatters.JsonFormatterTestCase.java

private static void validateDefault(final JsonObject json, final Collection<String> expectedKeys,
        final String expectedMessage) {
    final Set<String> remainingKeys = new HashSet<>(json.keySet());

    // Check all the expected keys
    for (String key : expectedKeys) {
        checkNonNull(json, key);//from ww w. j av a  2  s  . co m
        Assert.assertTrue("Missing key " + key + " from JSON object: " + json, remainingKeys.remove(key));
    }

    // Should have no more remaining keys
    Assert.assertTrue("There are remaining keys that were not validated: " + remainingKeys,
            remainingKeys.isEmpty());

    Assert.assertEquals("org.jboss.logging.Logger", json.getString("loggerClassName"));
    Assert.assertEquals(LoggingServiceActivator.LOGGER.getName(), json.getString("loggerName"));
    Assert.assertTrue("Invalid level found in " + json.get("level"), isValidLevel(json.getString("level")));
    Assert.assertEquals(expectedMessage, json.getString("message"));
}

From source file:edu.umass.cs.utils.Util.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public static Set<?> getOtherThan(Set<?> set, Object exclude) {
    Set<?> copy = new HashSet(set);
    copy.remove(exclude);
    return copy;//  w  w  w. j  a  v  a2 s .  com
}