List of usage examples for java.util Set retainAll
boolean retainAll(Collection<?> c);
From source file:ubic.GEOMMTx.MeSHMapperTest.java
private void evaluate(String text, Set<String> answers) throws GEOMMTXException { Set<String> predictions = getMeSHIDs(text, true); if (predictions.size() == 0) zeroCalls++;//from w ww .j a va 2s.co m predictedCount += predictions.size(); answerCount += answers.size(); answers.retainAll(predictions); matchedCount += answers.size(); if (answers.size() >= 1) atLeastOne++; }
From source file:org.waarp.gateway.kernel.rest.RestMethodHandler.java
/** * Will assign the intersection of both set of Methods * // ww w .j a va 2s . co m * @param selectedMethods * the selected Methods among available * @param validMethod * the validMethod for this handler */ protected void setIntersectionMethods(METHOD[] selectedMethods, METHOD... validMethod) { Set<METHOD> set = new HashSet<METHOD>(); for (METHOD method : validMethod) { set.add(method); } Set<METHOD> set2 = new HashSet<METHOD>(); for (METHOD method : selectedMethods) { set2.add(method); } set.retainAll(set2); METHOD[] methodsToSet = set.toArray(new METHOD[0]); setMethods(methodsToSet); }
From source file:de.anycook.db.mysql.DBMessage.java
public Integer getSessionIDFromUsers(Collection<Integer> userIds) throws SessionNotFoundException, SQLException { Set<Integer> merge = null; for (int userId : userIds) { Set<Integer> userSessions = getSessionIDsFromUser(userId); if (merge == null) merge = userSessions;//from w w w . j a v a 2s .c o m else merge.retainAll(userSessions); } for (Integer sessionId : merge) { if (getNumSessionUsers(sessionId) == userIds.size()) return sessionId; } throw new SessionNotFoundException(userIds); }
From source file:org.osate.atsv.integration.preparser.EngineConfigGenerator.java
private void generateInputFile() { try {//w w w . j a va 2s.c o m ATSVVarCollection inputs = getStartingInputs(); Map<String, ATSVVar> inputVars = inputs.getVars(); Set<String> convertedVarNames = eem.getConvertedConfiguratorNames(); convertedVarNames.retainAll(inputVars.keySet()); for (String varName : convertedVarNames) { inputs.addVar(varName, ATSVVariableType.DISCRETE_FLOAT, ATSVVariableType.getDefaultFromType(ATSVVariableType.DISCRETE_FLOAT)); } inputs.writeToFile(targetDirStr + "input.xml"); } catch (JAXBException e) { e.printStackTrace(); } }
From source file:dr.evomodel.continuous.ContinuousDiffusionStatistic.java
private static boolean onAncestralPathTaxa(Tree tree, NodeRef node, TaxonList taxonList) throws TreeUtils.MissingTaxonException { if (tree.isExternal(node)) return false; Set leafSet = TreeUtils.getDescendantLeaves(tree, node); int size = leafSet.size(); Set targetSet = TreeUtils.getLeavesForTaxa(tree, taxonList); leafSet.retainAll(targetSet); if (leafSet.size() > 0) { // if all leaves below are in target then check just above. if (leafSet.size() == size) { Set superLeafSet = TreeUtils.getDescendantLeaves(tree, tree.getParent(node)); superLeafSet.removeAll(targetSet); // the branch is on ancestral path if the super tree has some non-targets in it return (superLeafSet.size() > 0); } else//from ww w. j a v a 2 s . c o m return true; } else return false; }
From source file:org.romaframework.frontend.domain.searchengine.QueryOperation.java
private Set<String> updateResult(Set<String> result, String operationMode, Set<String> queryResult) { if (result == null) { result = queryResult;//ww w . j ava 2 s. c o m } else if (operationMode.equals(QueryOperator.OPERATOR_AND)) { result.retainAll(queryResult); } else { result.addAll(queryResult); } return result; }
From source file:cc.kave.commons.pointsto.evaluation.events.MRREvaluation.java
@Override protected void evaluate(List<ICompletionEvent> completionEvents, List<PointsToAnalysisFactory> ptFactories) throws IOException { for (PointsToAnalysisFactory ptFactory : ptFactories) { Map<ICoReTypeName, Map<ICompletionEvent, List<Usage>>> queries = createQueries(completionEvents, ptFactory);//from w w w . j a v a2 s. com Set<ICoReTypeName> types = getQueryTypes(queries.values()); int numQueryTypes = types.size(); Set<ICoReTypeName> storeTypes = getStoreTypes(); missingStoreTypes.put(ptFactory.getName(), ImmutableSet.copyOf(Sets.difference(types, storeTypes))); types.retainAll(storeTypes); log("%s: %d types, queries for %d\n", ptFactory.getName(), types.size(), numQueryTypes); for (ICoReTypeName type : types) { evaluateType(ptFactory.getName(), type, queries); } } }
From source file:ubic.BAMSandAllen.MatrixPairs.ConnectivityAndAllenDataPair.java
public void setDivision(String focusRegion) throws Exception { ExploreRegionNames explore = new ExploreRegionNames(this); StringToStringSetMap parents = explore.getParents(); Set<String> ROIs = parents.get(focusRegion); // some may have no exp ROIs.retainAll(getAllenDataColNames()); log.info(ROIs.size());//from ww w .j a va 2 s . co m removeAllenCols(ROIs); run(); }
From source file:com.datumbox.common.dataobjects.Dataset.java
/** * Removes completely a list of columns from the dataset. The meta-data of the * Dataset are updated./*from w ww. j a va 2s. c om*/ * * @param columnSet */ public void removeColumns(Set<Object> columnSet) { columnSet.retainAll(xDataTypes.keySet()); //keep only those columns that are already known to the Meta data of the Dataset if (columnSet.isEmpty()) { return; } //remove all the columns from the Meta data xDataTypes.keySet().removeAll(columnSet); for (Integer rId : this) { Record r = recordList.get(rId); AssociativeArray xData = r.getX().copy(); int d = xData.size(); xData.keySet().removeAll(columnSet); if (xData.size() != d) { r = new Record(xData, r.getY(), r.getYPredicted(), r.getYPredictedProbabilities()); recordList.put(rId, r); } } }
From source file:cc.kave.commons.pointsto.evaluation.ProjectTrainValidateEvaluation.java
private Set<ICoReTypeName> getStoreTypes(Collection<? extends UsageStore> stores) { Set<ICoReTypeName> storeTypes = new HashSet<>(); for (UsageStore store : stores) { Set<ICoReTypeName> types = store.getAllTypes().stream().filter(usageFilter::test) .collect(Collectors.toSet()); if (storeTypes.isEmpty()) { storeTypes.addAll(types);//from ww w . j a va2 s . c o m } else { storeTypes.retainAll(types); } } return storeTypes; }