List of usage examples for java.util HashSet addAll
boolean addAll(Collection<? extends E> c);
From source file:org.marketcetera.util.ws.types.TypeTest.java
private static <V> HashSet<V> toHashSet(List<V> in) { HashSet<V> out = new HashSet<V>(); out.addAll(in); return out;/*from w ww. j a va2s . co m*/ }
From source file:amie.keys.CombinationsExplorationNew.java
public static void discoverConditionalKeysForCondition(GraphNew newGraph, GraphNew graph, HashSet<Node> candidateKeys, Rule conditionRule) { HashSet<Node> newCandidateKeys = new HashSet<>(); for (Node candidateKey : candidateKeys) { // System.out.println("candidateKey:" + candidateKey); if (candidateKey.toExplore) { // System.out.println("candidate:" + candidateKey); // if (candidateKey.toExplore) { List<String> properties = candidateKey.mapToString(id2Property); Rule amieRule = buildAMIERule(properties, conditionRule); boolean isConditionalKey = isConditionaKey(amieRule); if (amieRule.getSupport() >= support && !isConditionalKey) { //System.out.println("Case 0"); if (!newGraph.graph.containsKey(candidateKey)) { //System.out.println("Case 1"); Node newCandidateKey = candidateKey.clone(); HashSet<Node> children = new HashSet<>(); newGraph.graph.put(newCandidateKey, children); newGraph.nodes.put(newCandidateKey, newCandidateKey); newCandidateKeys.add(newCandidateKey); } else { //System.out.println("Case 2"); HashSet<Node> children = new HashSet<>(); newGraph.graph.put(candidateKey, children); newCandidateKeys.add(candidateKey); }/* w ww .j a va 2 s . c o m*/ } // If the rule is a conditional above the support // and there is no a simpler key already discovered // then output it if (isConditionalKey && amieRule.getSupport() >= support && !isSubsumedByKey(amieRule, conditionRule, conditions2Keys)) { // System.out.println("KEY"); if (!newGraph.graph.containsKey(candidateKey)) { // System.out.println("clone"); Node newCandidateKey = candidateKey.clone(); System.out.println(Utilities.formatKey(amieRule)); conditions2Keys.put(conditionRule, amieRule); newCandidateKey.toExplore = false; HashSet<Node> children = new HashSet<>(); newGraph.graph.put(newCandidateKey, children); newGraph.nodes.put(newCandidateKey, newCandidateKey); newCandidateKeys.add(newCandidateKey); //System.out.println("Case 3"); } else { System.out.println(Utilities.formatKey(amieRule)); conditions2Keys.put(conditionRule, amieRule); candidateKey.toExplore = false; HashSet<Node> children = new HashSet<>(); newGraph.graph.put(candidateKey, children); newGraph.nodes.put(candidateKey, candidateKey); newCandidateKeys.add(candidateKey); //System.out.println("Case 4"); } // System.out.println(Utilities.formatKey(amieRule)); //conditions2Keys.put(conditionRule, amieRule); // candidateKey.toExplore = false; } } else { //System.out.println("Case 5"); newCandidateKeys.add(candidateKey); } } // System.out.println("newGraphBefore:" + newGraph); // createChildren HashSet<Node> allChildren = new HashSet<>(); // System.out.println("newCandidateKeys:"+newCandidateKeys); for (Node parent1 : newCandidateKeys) { // System.out.println("parent1:"+parent1); for (Node parent2 : newCandidateKeys) { if (parent1 != parent2 && parent1.toExplore != false && parent2.toExplore != false) { HashSet<Integer> newSet = new HashSet<>(); newSet.addAll(parent1.set); newSet.addAll(parent2.set); HashSet<Integer> condProp_KeyProp = new HashSet<>(); condProp_KeyProp.addAll(newSet); condProp_KeyProp.addAll(getRelations(conditionRule, property2Id)); // System.out.println("newSet:" + newSet); if ((newSet.size() == parent1.set.size() + 1) && (getSupport(newSet, conditionRule, support)) && GraphNew.containsASuperSetOf(CombinationsExplorationNew.nonKeysInt, condProp_KeyProp) != -1) { // System.out.println("enters"); Node child = new Node(newSet); if (hasFalseParent(newSet, newCandidateKeys)) { // System.out.println("falseParent"); child.toExplore = false; } HashSet<Node> children1 = newGraph.graph.get(parent1); children1.add(child); newGraph.graph.put(parent1, children1); newGraph.nodes.put(child, child); HashSet<Node> grandChildren = new HashSet<>(); newGraph.graph.put(child, grandChildren); HashSet<Node> children2 = newGraph.graph.get(parent2); children2.add(child); newGraph.graph.put(parent2, children2); allChildren.add(child); } } } } if (!allChildren.isEmpty()) { discoverConditionalKeysForCondition(newGraph, newGraph, allChildren, conditionRule); } }
From source file:com.datatorrent.lib.io.fs.FileSplitterInputTest.java
static Set<String> createData(String dataDirectory) throws IOException { Set<String> filePaths = Sets.newHashSet(); FileContext.getLocalFSFileContext().delete(new Path(new File(dataDirectory).getAbsolutePath()), true); HashSet<String> allLines = Sets.newHashSet(); for (int file = 0; file < 12; file++) { HashSet<String> lines = Sets.newHashSet(); for (int line = 0; line < 2; line++) { //padding 0 to file number so every file has 6 blocks. lines.add("f" + String.format("%02d", file) + "l" + line); }/*www. ja v a 2 s . c om*/ allLines.addAll(lines); File created = new File(dataDirectory, "file" + file + ".txt"); filePaths.add(created.getAbsolutePath()); FileUtils.write(created, StringUtils.join(lines, '\n')); } return filePaths; }
From source file:io.sloeber.core.managers.Manager.java
public static void addPackageURLs(HashSet<String> packageUrlsToAdd, boolean forceDownload) { HashSet<String> originalBoardUrls = new HashSet<>( Arrays.asList(ConfigurationPreferences.getBoardsPackageURLList())); packageUrlsToAdd.addAll(originalBoardUrls); ConfigurationPreferences.setBoardsPackageURLs(packageUrlsToAdd); loadIndices(forceDownload);/*from w ww .j ava 2 s .c o m*/ }
From source file:com.android.quicksearchbox.AbstractSuggestionExtras.java
public Collection<String> getExtraColumnNames() { HashSet<String> columns = new HashSet<String>(); columns.addAll(doGetExtraColumnNames()); if (mMore != null) { columns.addAll(mMore.getExtraColumnNames()); }/*www .j av a 2 s . co m*/ return columns; }
From source file:com.goncalomb.bukkit.nbteditor.TestBosEntities.java
@Test public void testBosEntities() { HashSet<EntityType> entityTypes = new HashSet<EntityType>(); entityTypes.addAll(Arrays.asList(EntityType.values())); entityTypes.removeAll(EntityNBT.getValidEntityTypes()); if (!entityTypes.isEmpty()) { System.out.print("Missing BoS entities: "); System.out.print(StringUtils.join(entityTypes, ", ")); System.out.println("."); }/*from ww w. j a v a 2 s .c om*/ }
From source file:org.georchestra.console.ws.backoffice.roles.RoleProtected.java
public void setListOfprotectedRoles(String[] listOfprotectedRoles) { HashSet<String> res = new HashSet<String>(); res.addAll(Arrays.asList(listOfprotectedRoles)); this.listOfprotectedRoles = res; }
From source file:org.georchestra.console.ws.backoffice.users.UserRule.java
public void setListOfprotectedUsers(String[] listOfprotectedUsers) { HashSet<String> res = new HashSet<String>(); res.addAll(Arrays.asList(listOfprotectedUsers)); this.listOfprotectedUsers = res; }
From source file:org.biopax.validator.rules.PhysicalEntityAmbiguousFeatureRule.java
public void check(final Validation validation, PhysicalEntity thing) { // Capture PEs that is both a participant of a conversion and a component of a complex if (!thing.getParticipantOf().isEmpty() && !thing.getComponentOf().isEmpty()) { HashSet<EntityFeature> efs = new HashSet<EntityFeature>(); efs.addAll(thing.getFeature()); efs.addAll(thing.getNotFeature()); // Do we have any information about the binding properties? If so, it's OK. for (EntityFeature ef : efs) { if (ef instanceof BindingFeature) { return; }// www . j a v a 2 s .c o m } // TODO: Call Emek's feature resolver function explicitly if the PE is to be fixed error(validation, thing, "ambiguous.feature", false, thing.getName()); } }
From source file:at.ac.univie.isc.asio.security.ExpandAuthoritiesContainerTest.java
@Theory public void maps_multiple_role_container_to_union(final Role one, final Role two) { final HashSet<GrantedAuthority> union = Sets.newHashSet(); union.add(one);/* w ww. j a va2 s .com*/ union.addAll(one.getGrantedAuthorities()); union.add(two); union.addAll(two.getGrantedAuthorities()); final Object[] expected = union.toArray(); final Collection<? extends GrantedAuthority> actual = subject.mapAuthorities(Arrays.asList(one, two)); assertThat(actual, containsInAnyOrder(expected)); }