List of usage examples for java.util HashSet addAll
boolean addAll(Collection<? extends E> c);
From source file:com.krawler.esp.handlers.basecampHandler.java
public static boolean cheForProject(String projName, String[] projNames) { boolean res = false; java.util.List l = java.util.Arrays.asList(projNames); java.util.HashSet<String> hs = new java.util.HashSet<String>(); hs.addAll(l); res = hs.add(projName);/* ww w .j av a2 s.c o m*/ return res; }
From source file:amie.keys.CombinationsExplorationNew.java
public static HashSet<HashSet<Integer>> buidPropertyGraphNew(int property) { HashSet<HashSet<Integer>> propertyPowerSets = new HashSet<>(); for (HashSet<Integer> nonKeyInt : nonKeysInt) { if (nonKeyInt.contains(property)) { HashSet<Integer> remainingSet = new HashSet<>(nonKeyInt); remainingSet.addAll(nonKeyInt); remainingSet.remove(property); propertyPowerSets.addAll(powerSet(remainingSet)); }/*from ww w . ja v a2 s .c om*/ } return propertyPowerSets; }
From source file:amie.keys.CombinationsExplorationNew.java
private static HashSet<Node> createChildren(GraphNew newGraph, HashSet<Node> parents, Rule conditionRule) { HashSet<Node> allChildren = new HashSet<>(); for (Node parent1 : parents) { for (Node parent2 : parents) { if (parent1 != parent2) { HashSet<Integer> newSet = new HashSet<>(); newSet.addAll(parent1.set); newSet.addAll(parent2.set); HashSet<Integer> newSet2 = new HashSet<>(); newSet2.addAll(newSet);/*from w ww . ja v a 2s . com*/ newSet2.addAll(newSet); if ((newSet.size() == parent1.set.size() + 1) && (getSupport(newSet2, conditionRule, support))) { Node child = new Node(newSet); HashSet<Node> children1 = newGraph.graph.get(parent1); children1.add(child); newGraph.nodes.put(child, child); newGraph.graph.put(parent1, children1); HashSet<Node> children2 = newGraph.graph.get(parent2); children2.add(child); newGraph.graph.put(parent2, children2); allChildren.add(child); //System.out.println("child:"+child); } } } } // System.out.println("allChildren:" + allChildren); return allChildren; }
From source file:amie.keys.CombinationsExplorationNew.java
public static HashSet<HashSet<Integer>> simplifyHashNonKeySet(HashSet<HashSet<Integer>> nonKeySet) { HashSet<HashSet<Integer>> newnonKeySet = new HashSet<HashSet<Integer>>(); newnonKeySet.addAll(nonKeySet); for (HashSet set : nonKeySet) { for (HashSet set2 : nonKeySet) { if (set2 != set && set2.containsAll(set)) { newnonKeySet.remove(set); break; }// w w w. j av a 2s. c om } } return newnonKeySet; }
From source file:amie.keys.CombinationsExplorationNew.java
public static HashSet<HashSet<Integer>> powerSet(HashSet<Integer> originalSet) { HashSet<HashSet<Integer>> sets = new HashSet<HashSet<Integer>>(); if (originalSet.isEmpty()) { sets.add(new HashSet<Integer>()); return sets; }/*from ww w . j ava 2s.c o m*/ List<Integer> list = new ArrayList<Integer>(originalSet); int head = list.get(0); HashSet<Integer> rest = new HashSet<Integer>(list.subList(1, list.size())); for (HashSet<Integer> set : powerSet(rest)) { HashSet<Integer> newSet = new HashSet<Integer>(); newSet.add(head); newSet.addAll(set); sets.add(newSet); sets.add(set); } return sets; }
From source file:amie.keys.CombinationsExplorationNew.java
private static GraphNew mergeGraphNews(GraphNew currentGraphNew, GraphNew graph2, HashSet<Node> currentGraphNewTopNodes, HashSet<Integer> conditionProperties) { HashSet<Node> childrenNodes = new HashSet<>(); for (Node currentGraphNewtopNode : currentGraphNewTopNodes) { if (currentGraphNewtopNode.toExplore) { // System.out.println("currentGraphNewtopNode:"+currentGraphNewtopNode); if (graph2.graph.containsKey(currentGraphNewtopNode)) { // System.out.println("yes"); Node nodeInGraphNew2 = graph2.getNode(currentGraphNewtopNode); if (!nodeInGraphNew2.toExplore) { // System.out.println("no2"); currentGraphNewtopNode.toExplore = false; currentGraphNew.getAndCreateNode(currentGraphNewtopNode); } else { // System.out.println("yes2"); HashSet<Integer> allProperties = new HashSet<>(); allProperties.addAll(conditionProperties); allProperties.addAll(currentGraphNewtopNode.set); // System.out.println("allProperties:"+allProperties); if (!containsSubSet(allProperties)) { // System.out.println("no3"); currentGraphNewtopNode.toExplore = false; currentGraphNew.getAndCreateNode(currentGraphNewtopNode); }//from w w w. j a v a 2 s . c om } } else { // System.out.println("no"); currentGraphNewtopNode.toExplore = false; currentGraphNew.getAndCreateNode(currentGraphNewtopNode); } } if (currentGraphNew.graph.get(currentGraphNewtopNode) != null) { childrenNodes.addAll(currentGraphNew.graph.get(currentGraphNewtopNode)); } } if (!childrenNodes.isEmpty()) { mergeGraphNews(currentGraphNew, graph2, childrenNodes, conditionProperties); } return currentGraphNew; }
From source file:com.github.maven_nar.NarUtil.java
static Set findInstallNameToolCandidates(final File[] files, final Log log) throws MojoExecutionException, MojoFailureException { final HashSet candidates = new HashSet(); for (final File file2 : files) { final File file = file2; if (!file.exists()) { continue; }/*from www . j a v a 2 s . c om*/ if (file.isDirectory()) { candidates.addAll(findInstallNameToolCandidates(file.listFiles(), log)); } final String fileName = file.getName(); if (file.isFile() && file.canWrite() && (fileName.endsWith(".so") || fileName.endsWith(".dylib") || fileName.endsWith(".jnilib"))) { candidates.add(file); } } return candidates; }
From source file:com.dtolabs.rundeck.core.utils.NodeSet.java
/** * Return true if the input string is found in the set of values. * The inputSelector can contain boolean and using the "+" symbol, and boolean or using the "," symbol. * E.g.: "a + b" - matches if both "a" and "b" are in the value set * E.g.: "a , b" - matches if either "a" or "b" are in the value set * * @param inputSelector//from ww w . j a v a 2s .co m * * @return */ static boolean matchesInputSet(String inputSelector, Collection propSet) { if (null == propSet || propSet.size() < 1) { return false; } if (null == inputSelector || "".equals(inputSelector.trim())) { return false; } if (inputSelector.contains("+") || inputSelector.contains(",")) { HashSet orSet = new HashSet(); orSet.addAll(Arrays.asList(inputSelector.split(","))); for (Object anOrSet : orSet) { String clause = (String) anOrSet; HashSet set = new HashSet(); set.addAll(Arrays.asList(clause.split("\\+"))); boolean found = true; for (Object aSet : set) { String tag = (String) aSet; if (!propSet.contains(tag.trim())) { //try regular expression match boolean rematch = false; for (Object aPropSet : propSet) { String item = (String) aPropSet; if (matchRegexOrEquals(tag, item)) { rematch = true; break; } } if (!rematch) { found = false; } } } if (found) { return true; } } return false; } else { boolean contain = propSet.contains(inputSelector); boolean rematch = false; for (Object aPropSet : propSet) { String item = (String) aPropSet; if (matchRegexOrEquals(inputSelector, item)) { rematch = true; break; } } return rematch || contain; } }
From source file:org.apache.samza.system.kafka.KafkaSystemAdmin.java
/** * A helper method that takes oldest, newest, and upcoming offsets for each * system stream partition, and creates a single map from stream name to * SystemStreamMetadata.//w w w . ja v a2s . co m * * @param newestOffsets map of SSP to newest offset * @param oldestOffsets map of SSP to oldest offset * @param upcomingOffsets map of SSP to upcoming offset * @return a {@link Map} from {@code system} to {@link SystemStreamMetadata} */ @VisibleForTesting static Map<String, SystemStreamMetadata> assembleMetadata(Map<SystemStreamPartition, String> oldestOffsets, Map<SystemStreamPartition, String> newestOffsets, Map<SystemStreamPartition, String> upcomingOffsets) { HashSet<SystemStreamPartition> allSSPs = new HashSet<>(); allSSPs.addAll(oldestOffsets.keySet()); allSSPs.addAll(newestOffsets.keySet()); allSSPs.addAll(upcomingOffsets.keySet()); Map<String, SystemStreamMetadata> assembledMetadata = allSSPs.stream() .collect(Collectors.groupingBy(SystemStreamPartition::getStream)).entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, entry -> { Map<Partition, SystemStreamMetadata.SystemStreamPartitionMetadata> partitionMetadata = entry .getValue().stream() .collect(Collectors.toMap(SystemStreamPartition::getPartition, ssp -> new SystemStreamMetadata.SystemStreamPartitionMetadata( oldestOffsets.getOrDefault(ssp, null), newestOffsets.getOrDefault(ssp, null), upcomingOffsets.get(ssp)))); return new SystemStreamMetadata(entry.getKey(), partitionMetadata); })); return assembledMetadata; }
From source file:amie.keys.CombinationsExplorationNew.java
/** * * @param ruleToExtendWith/* w ww . j a v a 2s .c om*/ * @param ruleToGraphNewFirstLevel * @param ruleToGraphNewLastLevel * @param kb */ private static void discoverConditionalKeysPerLevel(HashMap<Rule, HashSet<String>> ruleToExtendWith, HashMap<Rule, GraphNew> ruleToGraphNewFirstLevel, HashMap<Rule, GraphNew> ruleToGraphNewLastLevel) { HashMap<Rule, GraphNew> ruleToGraphNewThisLevel = new HashMap<>(); for (Rule currentRule : ruleToExtendWith.keySet()) { for (String conditionProperty : ruleToExtendWith.get(currentRule)) { if (Utilities.getRelationIds(currentRule, property2Id).last() > property2Id .get(conditionProperty)) { GraphNew graph = ruleToGraphNewLastLevel.get(currentRule); GraphNew currentGraphNew = (GraphNew) graph.clone(); Integer propertyId = property2Id.get(conditionProperty); HashSet<Integer> propertiesSet = new HashSet<>(); propertiesSet.add(propertyId); Node node = currentGraphNew.createNode(propertiesSet); node.toExplore = false; Iterable<Rule> conditions = Utilities.getConditions(currentRule, conditionProperty, (int) support, kb); for (Rule conditionRule : conditions) { Rule complementaryRule = getComplementaryRule(conditionRule); if (!ruleToGraphNewFirstLevel.containsKey(complementaryRule)) { // We should never fall in this case for (Rule r : ruleToGraphNewFirstLevel.keySet()) { System.out.println(r.getDatalogBasicRuleString()); } System.out.println(complementaryRule.getDatalogBasicRuleString()); System.out.println(complementaryRule + " not found in the first level graph"); } GraphNew complementaryGraphNew = ruleToGraphNewFirstLevel.get(complementaryRule); GraphNew newGraphNew = (GraphNew) currentGraphNew.clone(); HashSet<Integer> conditionProperties = new HashSet<>(); conditionProperties.addAll(getRelations(conditionRule, property2Id)); conditionProperties.addAll(getRelations(currentRule, property2Id)); newGraphNew = mergeGraphNews(newGraphNew, complementaryGraphNew, newGraphNew.topGraphNodes(), conditionProperties); discoverConditionalKeysForComplexConditions(newGraphNew, newGraphNew.topGraphNodes(), conditionRule); ruleToGraphNewThisLevel.put(conditionRule, newGraphNew); } } } } HashMap<Rule, HashSet<String>> newRuleToExtendWith = new HashMap<>(); for (Rule conRule : ruleToGraphNewThisLevel.keySet()) { GraphNew newGraphNew = ruleToGraphNewThisLevel.get(conRule); for (Node node : newGraphNew.topGraphNodes()) { HashSet<String> properties = new HashSet<>(); if (node.toExplore) { Iterator<Integer> it = node.set.iterator(); int prop = it.next(); String propertyStr = id2Property.get(prop); properties.add(propertyStr); } if (properties.size() != 0) { newRuleToExtendWith.put(conRule, properties); } } } if (newRuleToExtendWith.size() != 0) { discoverConditionalKeysPerLevel(newRuleToExtendWith, ruleToGraphNewFirstLevel, ruleToGraphNewThisLevel); } }