Java Code Examples for java.util.TreeSet#removeAll()
The following examples show how to use
java.util.TreeSet#removeAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlAbstractParserImpl.java From Bats with Apache License 2.0 | 6 votes |
/** * Builds a comma-separated list of JDBC reserved words. */ private String constructSql92ReservedWordList() { StringBuilder sb = new StringBuilder(); TreeSet<String> jdbcReservedSet = new TreeSet<>(); jdbcReservedSet.addAll(tokenSet); jdbcReservedSet.removeAll(SQL_92_RESERVED_WORD_SET); jdbcReservedSet.removeAll(nonReservedKeyWordSet); int j = 0; for (String jdbcReserved : jdbcReservedSet) { if (j++ > 0) { sb.append(","); } sb.append(jdbcReserved); } return sb.toString(); }
Example 2
Source File: AbstractTaggerTest.java From SolrTextTagger with Apache License 2.0 | 6 votes |
/** Asserts the sorted arrays are equals, with a helpful error message when not. * @param message * @param expecteds * @param actuals */ public void assertSortedArrayEquals(String message, Object[] expecteds, Object[] actuals) { AssertionError error = null; try { assertArrayEquals(null, expecteds, actuals); } catch (AssertionError e) { error = e; } if (error == null) return; TreeSet<Object> expectedRemaining = new TreeSet<>(Arrays.asList(expecteds)); expectedRemaining.removeAll(Arrays.asList(actuals)); if (!expectedRemaining.isEmpty()) fail(message+": didn't find expected "+expectedRemaining.first()+" (of "+expectedRemaining.size()+"); "+ error); TreeSet<Object> actualsRemaining = new TreeSet<>(Arrays.asList(actuals)); actualsRemaining.removeAll(Arrays.asList(expecteds)); fail(message+": didn't expect "+actualsRemaining.first()+" (of "+actualsRemaining.size()+"); "+ error); }
Example 3
Source File: TaggerTestCase.java From lucene-solr with Apache License 2.0 | 6 votes |
/** Asserts the sorted arrays are equals, with a helpful error message when not.*/ public void assertSortedArrayEquals(String message, Object[] expecteds, Object[] actuals) { AssertionError error = null; try { assertArrayEquals(null, expecteds, actuals); } catch (AssertionError e) { error = e; } if (error == null) return; TreeSet<Object> expectedRemaining = new TreeSet<>(Arrays.asList(expecteds)); expectedRemaining.removeAll(Arrays.asList(actuals)); if (!expectedRemaining.isEmpty()) fail(message+": didn't find expected "+expectedRemaining.first()+" (of "+expectedRemaining.size()+"); "+ error); TreeSet<Object> actualsRemaining = new TreeSet<>(Arrays.asList(actuals)); actualsRemaining.removeAll(Arrays.asList(expecteds)); fail(message+": didn't expect "+actualsRemaining.first()+" (of "+actualsRemaining.size()+"); "+ error); }
Example 4
Source File: Experiment.java From Heracles with GNU General Public License v3.0 | 6 votes |
public Experiment setCrossValidation(int repetitions, int nrFolds, double... remainingSubSetProportions){ if (!run && nrFolds > 1 && !dataSplit){ this.nrFolds = nrFolds; this.subSetProportions = remainingSubSetProportions; this.repetitions = repetitions; double[] folds = new double[nrFolds]; for (int i = 0; i < nrFolds; i++){ folds[i] = (1.0/nrFolds); } for (int rep = 0; rep < repetitions; rep++){ ArrayList<HashSet<Span>> testFolds = dataset.createSubSets(unitOfAnalysisSpanType, folds); TreeSet<Span> allData = dataset.getSpans(unitOfAnalysisSpanType); for (int i = 0; i < nrFolds; i++){ TreeSet<Span> nonTestData = new TreeSet<>(); nonTestData.addAll(allData); nonTestData.removeAll(testFolds.get(i)); ArrayList<HashSet<Span>> foldSubSets = Dataset.createSubSets(nonTestData, remainingSubSetProportions); foldSubSets.add(testFolds.get(i)); multipleDataSubSets.add(foldSubSets); } } dataSplit = true; } return this; }
Example 5
Source File: TestNode2ContainerMap.java From hadoop-ozone with Apache License 2.0 | 5 votes |
/** * This test asserts that processReport is able to detect missing containers * if they are misssing from a list. * * @throws SCMException */ @Test public void testProcessReportDetectMissingContainers() throws SCMException { Node2ContainerMap map = new Node2ContainerMap(); UUID key = getFirstKey(); TreeSet<ContainerID> values = testData.get(key); map.insertNewDatanode(key, values); final int removeCount = 100; Random r = new Random(); ContainerID first = values.first(); TreeSet<ContainerID> removedContainers = new TreeSet<>(); // Pick a random container to remove it is ok to collide no issues. for (int x = 0; x < removeCount; x++) { int startBase = (int) first.getId(); long cTemp = r.nextInt(values.size()); removedContainers.add(new ContainerID(cTemp + startBase)); } // This set is a new set with some containers removed. TreeSet<ContainerID> newContainersSet = new TreeSet<>(values); newContainersSet.removeAll(removedContainers); ReportResult result = map.processReport(key, newContainersSet); //Assert that expected size of missing container is same as addedContainers Assert.assertEquals(ReportResult.ReportStatus.MISSING_ENTRIES, result.getStatus()); Assert.assertEquals(removedContainers.size(), result.getMissingEntries().size()); // Assert that the Container IDs are the same as we added new. Assert.assertTrue("All missing containers not found.", result.getMissingEntries().removeAll(removedContainers)); }
Example 6
Source File: RepositoryManagerImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public SortedSet<RepositoryInfo> getAllRepositories() { TreeSet<RepositoryInfo> res = repos.getAll(); if (myRepos != null) { // Add myRepos to get correct ranking. res.removeAll(myRepos.values()); res.addAll(myRepos.keySet()); } return res; }
Example 7
Source File: 12504 Updating a Dictionary.java From UVA with GNU General Public License v3.0 | 5 votes |
public static void main (String [] args) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int testCaseCount=Integer.parseInt(br.readLine()); for (int i=0;i<testCaseCount;i++) { TreeMap<String,String> oldDict=new TreeMap<>(); TreeMap<String,String> newDict=new TreeMap<>(); updateDict(oldDict,br.readLine()); updateDict(newDict,br.readLine()); TreeSet<String> newKeys=new TreeSet<>(); newKeys.addAll(newDict.keySet()); newKeys.removeAll(oldDict.keySet()); TreeSet<String> removedKeys=new TreeSet<>(); removedKeys.addAll(oldDict.keySet()); removedKeys.removeAll(newDict.keySet()); TreeSet<String> changedKeys=new TreeSet<>(); changedKeys.addAll(oldDict.keySet()); changedKeys.retainAll(newDict.keySet()); String [] changedKeysAry=changedKeys.toArray(new String [changedKeys.size()]); for (String s : changedKeysAry) if (oldDict.get(s).equals(newDict.get(s))) changedKeys.remove(s); StringBuilder sb=new StringBuilder(); sb.append(toStr("+",newKeys)); sb.append(toStr("-",removedKeys)); sb.append(toStr("*",changedKeys)); if (sb.length()==0) sb.append("No changes\n"); System.out.println(sb.toString()); } }
Example 8
Source File: ReportCalculator.java From olca-app with Mozilla Public License 2.0 | 5 votes |
/** * Add zero-contributions for processes that were not found in a variant result. */ private void addDefaultContributions(Set<Long> ids, Set<Long> foundIds, VariantResult varResult) { TreeSet<Long> notFound = new TreeSet<>(ids); notFound.removeAll(foundIds); for (long id : notFound) { Contribution<Long> con = new Contribution<>(); varResult.contributions.add(con); con.amount = 0; con.isRest = false; con.item = id; } }
Example 9
Source File: NodeRoleDimension.java From batfish with Apache License 2.0 | 5 votes |
/** * Create a map from each node name to its set of roles * * @param nodeNames The universe of nodes that we need to classify * @return The created map */ public SortedMap<String, String> createNodeRolesMap(Set<String> nodeNames) { // convert to a set that supports element removal TreeSet<String> nodes = new TreeSet<>(nodeNames); SortedMap<String, String> nodeRolesMap = new TreeMap<>(); for (RoleDimensionMapping rdmap : _roleDimensionMappings) { SortedMap<String, String> currMap = rdmap.createNodeRolesMap(nodes); nodes.removeAll(currMap.keySet()); nodeRolesMap.putAll(currMap); } return nodeRolesMap; }
Example 10
Source File: PDGObjectSliceUnion.java From JDeodorant with MIT License | 5 votes |
private boolean objectSliceEqualsMethodBody() { int sliceSize = sliceNodes.size(); if(sliceSize == methodSize) return true; else if(sliceSize == methodSize - 1) { TreeSet<GraphNode> nonIncludedInSliceMethodNodes = new TreeSet<GraphNode>(pdg.nodes); nonIncludedInSliceMethodNodes.removeAll(sliceNodes); PDGNode pdgNode = (PDGNode)nonIncludedInSliceMethodNodes.first(); if(pdgNode instanceof PDGExitNode) return true; } return false; }
Example 11
Source File: FolderAuthorizationStrategyManagementLink.java From folder-auth-plugin with MIT License | 5 votes |
@Nonnull static Set<Permission> getSafePermissions(Set<PermissionGroup> groups) { TreeSet<Permission> safePermissions = new TreeSet<>(Permission.ID_COMPARATOR); groups.stream().map(PermissionGroup::getPermissions).forEach(safePermissions::addAll); safePermissions.removeAll(PermissionWrapper.DANGEROUS_PERMISSIONS); return safePermissions; }
Example 12
Source File: SortedSetRelation.java From fitnotifications with Apache License 2.0 | 4 votes |
/** * Utility that could be on SortedSet. Allows faster implementation than * what is in Java for doing addAll, removeAll, retainAll, (complementAll). * @param a first set * @param relation the relation filter, using ANY, CONTAINS, etc. * @param b second set * @return the new set */ public static <T extends Object & Comparable<? super T>> SortedSet<? extends T> doOperation(SortedSet<T> a, int relation, SortedSet<T> b) { // TODO: optimize this as above TreeSet<? extends T> temp; switch (relation) { case ADDALL: a.addAll(b); return a; case A: return a; // no action case B: a.clear(); a.addAll(b); return a; case REMOVEALL: a.removeAll(b); return a; case RETAINALL: a.retainAll(b); return a; // the following is the only case not really supported by Java // although all could be optimized case COMPLEMENTALL: temp = new TreeSet<T>(b); temp.removeAll(a); a.removeAll(b); a.addAll(temp); return a; case B_REMOVEALL: temp = new TreeSet<T>(b); temp.removeAll(a); a.clear(); a.addAll(temp); return a; case NONE: a.clear(); return a; default: throw new IllegalArgumentException("Relation " + relation + " out of range"); } }
Example 13
Source File: DefaultTimepointLimiter.java From date_picker_converter with Apache License 2.0 | 4 votes |
private TreeSet<Timepoint> getExclusiveSelectableTimes(TreeSet<Timepoint> selectable, TreeSet<Timepoint> disabled) { TreeSet<Timepoint> output = new TreeSet<>(selectable); output.removeAll(disabled); return output; }
Example 14
Source File: SortedSetRelation.java From j2objc with Apache License 2.0 | 4 votes |
/** * Utility that could be on SortedSet. Allows faster implementation than * what is in Java for doing addAll, removeAll, retainAll, (complementAll). * @param a first set * @param relation the relation filter, using ANY, CONTAINS, etc. * @param b second set * @return the new set */ public static <T extends Object & Comparable<? super T>> SortedSet<? extends T> doOperation(SortedSet<T> a, int relation, SortedSet<T> b) { // TODO: optimize this as above TreeSet<? extends T> temp; switch (relation) { case ADDALL: a.addAll(b); return a; case A: return a; // no action case B: a.clear(); a.addAll(b); return a; case REMOVEALL: a.removeAll(b); return a; case RETAINALL: a.retainAll(b); return a; // the following is the only case not really supported by Java // although all could be optimized case COMPLEMENTALL: temp = new TreeSet<T>(b); temp.removeAll(a); a.removeAll(b); a.addAll(temp); return a; case B_REMOVEALL: temp = new TreeSet<T>(b); temp.removeAll(a); a.clear(); a.addAll(temp); return a; case NONE: a.clear(); return a; default: throw new IllegalArgumentException("Relation " + relation + " out of range"); } }
Example 15
Source File: SortedSetRelation.java From trekarta with GNU General Public License v3.0 | 4 votes |
/** * Utility that could be on SortedSet. Allows faster implementation than * what is in Java for doing addAll, removeAll, retainAll, (complementAll). * @param a first set * @param relation the relation filter, using ANY, CONTAINS, etc. * @param b second set * @return the new set */ public static <T extends Object & Comparable<? super T>> SortedSet<? extends T> doOperation(SortedSet<T> a, int relation, SortedSet<T> b) { // TODO: optimize this as above TreeSet<? extends T> temp; switch (relation) { case ADDALL: a.addAll(b); return a; case A: return a; // no action case B: a.clear(); a.addAll(b); return a; case REMOVEALL: a.removeAll(b); return a; case RETAINALL: a.retainAll(b); return a; // the following is the only case not really supported by Java // although all could be optimized case COMPLEMENTALL: temp = new TreeSet<T>(b); temp.removeAll(a); a.removeAll(b); a.addAll(temp); return a; case B_REMOVEALL: temp = new TreeSet<T>(b); temp.removeAll(a); a.clear(); a.addAll(temp); return a; case NONE: a.clear(); return a; default: throw new IllegalArgumentException("Relation " + relation + " out of range"); } }
Example 16
Source File: Location.java From unitime with Apache License 2.0 | 4 votes |
public static TreeSet findAllAvailableExamLocations(ExamPeriod period) { TreeSet locations = findAllExamLocations(period.getSession().getUniqueId(),period.getExamType()); locations.removeAll(findNotAvailableExamLocations(period.getUniqueId())); return locations; }
Example 17
Source File: DefaultTimepointLimiter.java From MaterialDateTimePicker with Apache License 2.0 | 4 votes |
@NonNull private TreeSet<Timepoint> getExclusiveSelectableTimes(@NonNull TreeSet<Timepoint> selectable, @NonNull TreeSet<Timepoint> disabled) { TreeSet<Timepoint> output = new TreeSet<>(selectable); output.removeAll(disabled); return output; }
Example 18
Source File: SetReferenceTransformer.java From carbon-device-mgt with Apache License 2.0 | 3 votes |
/** * Use the Set theory to find the objects to delete and objects to add The difference of objects in existingSet and newSet needed to be deleted new roles to add = newSet - The intersection of roles in existingSet and newSet * @param currentList * @param nextList */ public void transform(List<T> currentList, List<T> nextList){ TreeSet<T> existingSet = new TreeSet<T>(currentList); TreeSet<T> newSet = new TreeSet<T>(nextList); existingSet.removeAll(newSet); objectsToRemove = new ArrayList<T>(existingSet); // Clearing and re-initializing the set existingSet = new TreeSet<T>(currentList); newSet.removeAll(existingSet); objectsToAdd = new ArrayList<T>(newSet); }
Example 19
Source File: SetReferenceTransformer.java From carbon-device-mgt with Apache License 2.0 | 3 votes |
/** * Use the Set theory to find the objects to delete and objects to add The difference of objects in existingSet and newSet needed to be deleted new roles to add = newSet - The intersection of roles in existingSet and newSet * @param currentList * @param nextList */ public void transform(List<T> currentList, List<T> nextList){ TreeSet<T> existingSet = new TreeSet<T>(currentList); TreeSet<T> newSet = new TreeSet<T>(nextList); existingSet.removeAll(newSet); objectsToRemove = new ArrayList<T>(existingSet); // Clearing and re-initializing the set existingSet = new TreeSet<T>(currentList); newSet.removeAll(existingSet); objectsToAdd = new ArrayList<T>(newSet); }
Example 20
Source File: SetReferenceTransformer.java From carbon-device-mgt with Apache License 2.0 | 3 votes |
/** * Use the Set theory to find the objects to delete and objects to add The difference of objects in existingSet and newSet needed to be deleted new roles to add = newSet - The intersection of roles in existingSet and newSet * @param currentList * @param nextList */ public void transform(List<T> currentList, List<T> nextList){ TreeSet<T> existingSet = new TreeSet<T>(currentList); TreeSet<T> newSet = new TreeSet<T>(nextList);; existingSet.removeAll(newSet); objectsToRemove = new ArrayList<>(existingSet); // Clearing and re-initializing the set existingSet = new TreeSet<T>(currentList); newSet.removeAll(existingSet); objectsToAdd = new ArrayList<T>(newSet); }