List of usage examples for java.util LinkedHashSet LinkedHashSet
public LinkedHashSet()
From source file:edu.stanford.muse.groups.SimilarGroupMethods.java
/** * find intersections till fixed point and compute frequency for each group. * returns a run log and list of similar groups *///from w ww .j ava 2s . c o m private static <T extends Comparable<? super T>> Set<SimilarGroup<T>> intersectGroups( Collection<SimilarGroup<T>> startingGroups, int minSize, GroupAlgorithmStats stats) { boolean fixedPoint = false; Set<SimilarGroup<T>> candidates = new LinkedHashSet<SimilarGroup<T>>(); // add all the actually occurring (exact) recipient sets candidates.addAll(startingGroups); // allGroups will be the master list of all groups that we have (uptil // the previous iteration) Set<SimilarGroup<T>> newGroupsPrevIteration = candidates; // newGroupsPrevIteration will start off as all groups in the first iteration, // but reduce to only the newly derived groups at the end of each iteration. // we do this so as have to check for intersections only between the newly // derived groups and all other groups. trying to intersect each group with // every other group known in each iteration might be too expensive. int iteration = 1; while (!fixedPoint) { // newGroups will be the groups we derive in this iteration Set<SimilarGroup<T>> newGroups = new LinkedHashSet<SimilarGroup<T>>(); // brute force: all to all intersection between existing groups and // groups newly created in prev. iteration can be made more efficient // by maintaining person -> group map and only intersecting those // groups that have at least one person in common. for (SimilarGroup<T> g1 : candidates) for (SimilarGroup<T> g2 : newGroupsPrevIteration) { SimilarGroup<T> newGroup = new SimilarGroup<T>(g1.intersect(g2)); if (newGroup.size() == 0) continue; if (newGroup.size() < minSize) continue; // add to newGroups if we dont already have it if (!candidates.contains(newGroup) && !newGroups.contains(newGroup)) newGroups.add(newGroup); } log.info("Intersection iteration " + iteration + ": " + newGroups.size() + " new sets"); stats.intersectionGroupsAdded.add(new GroupStats(newGroups)); for (SimilarGroup<T> g : newGroups) log.debug("new group: " + g); candidates.addAll(newGroups); iteration++; // reached fixed point when no new groups fixedPoint = (newGroups.size() == 0); newGroupsPrevIteration = newGroups; } return candidates; }
From source file:org.withinsea.izayoi.adapter.springmvc.SpringBeanSource.java
@Override public Set<String> names() { Set<String> names = new LinkedHashSet<String>(); names.add("applicationContext"); names.addAll(Arrays.asList(appctx.getBeanDefinitionNames())); return names; }
From source file:com.espertech.esper.rowregex.EventRowRegexHelper.java
/** * Inspect variables recursively./*from w w w. j av a 2s . co m*/ * @param parent parent regex expression node * @param isMultiple if the variable in the stack is multiple of single * @param variablesSingle single variables list * @param variablesMultiple group variables list */ protected static void recursiveInspectVariables(RowRegexExprNode parent, boolean isMultiple, Set<String> variablesSingle, Set<String> variablesMultiple) { if (parent instanceof RowRegexExprNodeNested) { RowRegexExprNodeNested nested = (RowRegexExprNodeNested) parent; for (RowRegexExprNode child : parent.getChildNodes()) { recursiveInspectVariables(child, nested.getType().isMultipleMatches() || isMultiple, variablesSingle, variablesMultiple); } } else if (parent instanceof RowRegexExprNodeAlteration) { for (RowRegexExprNode childAlteration : parent.getChildNodes()) { LinkedHashSet<String> singles = new LinkedHashSet<String>(); LinkedHashSet<String> multiples = new LinkedHashSet<String>(); recursiveInspectVariables(childAlteration, isMultiple, singles, multiples); variablesMultiple.addAll(multiples); variablesSingle.addAll(singles); } variablesSingle.removeAll(variablesMultiple); } else if (parent instanceof RowRegexExprNodeAtom) { RowRegexExprNodeAtom atom = (RowRegexExprNodeAtom) parent; String name = atom.getTag(); if (variablesMultiple.contains(name)) { return; } if (variablesSingle.contains(name)) { variablesSingle.remove(name); variablesMultiple.add(name); return; } if (atom.getType().isMultipleMatches()) { variablesMultiple.add(name); return; } if (isMultiple) { variablesMultiple.add(name); } else { variablesSingle.add(name); } } else { for (RowRegexExprNode child : parent.getChildNodes()) { recursiveInspectVariables(child, isMultiple, variablesSingle, variablesMultiple); } } }
From source file:edu.uiowa.icts.bluebutton.json.view.FindLoincCodeList.java
public String getLoincCodeCsvList() { Set<String> loincCodeSet = new LinkedHashSet<String>(); for (Vitals v : this.vitalsList) { for (VitalsResult vr : v.getResults()) { if (vr.getLoincCodeName() != null) { loincCodeSet.add(vr.getLoincCodeName()); }//w ww . ja v a 2 s .c om } } for (Lab lab : this.labList) { for (LabResult labResult : lab.getResults()) { if (labResult.getLoincCodeName() != null) { loincCodeSet.add(labResult.getLoincCodeName()); } } } return StringUtils.join(loincCodeSet, ","); }
From source file:de.vandermeer.skb.interfaces.coin.TailsErrorWithErrors.java
/** * Creates a new error coin with given value and errors. * @param <R> type of the return value * @param <M> the message type for the set * @param value the actual return value/*from www .j av a2s. com*/ * @return new error coin */ static <R, M> TailsErrorWithErrors<R, M> create(final R value) { return new TailsErrorWithErrors<R, M>() { final Set<M> errorSet = new LinkedHashSet<>(); @Override public Set<M> getErrorMessages() { return this.errorSet; } @Override public R getReturn() { return value; } }; }
From source file:com.netflix.nicobar.core.module.ScriptModuleUtils.java
/** * Find all of the classes in the module that are subclasses or equal to the target class * @param module module to search//from www . ja v a 2s. co m * @param targetClass target type to search for * @return first instance that matches the given type */ public static Set<Class<?>> findAssignableClasses(ScriptModule module, Class<?> targetClass) { Set<Class<?>> result = new LinkedHashSet<Class<?>>(); for (Class<?> candidateClass : module.getLoadedClasses()) { if (targetClass.isAssignableFrom(candidateClass)) { result.add(candidateClass); } } return result; }
From source file:de.vandermeer.skb.interfaces.coin.HeadsSuccessWithInfo.java
/** * Creates a new success coin with given value and information. * @param <R> type of the return value * @param <M> the message type for the set * @param value the actual return value/*from www. j av a 2 s. c o m*/ * @return new success coin */ static <R, M> HeadsSuccessWithInfo<R, M> create(final R value) { return new HeadsSuccessWithInfo<R, M>() { final Set<M> infoSet = new LinkedHashSet<>(); @Override public R getReturn() { return value; } @Override public Set<M> getInfoMessages() { return this.infoSet; } }; }
From source file:io.reactiverse.vertx.maven.plugin.utils.WebJars.java
/** * Checks whether the given file is a WebJar or not (http://www.webjars.org/documentation). * The check is based on the presence of {@literal META-INF/resources/webjars/} directory in the jar file. * * @param file the file.//from w w w . j av a 2 s.com * @return {@literal true} if it's a bundle, {@literal false} otherwise. */ public static boolean isWebJar(Log log, File file) { if (file == null) { return false; } Set<String> found = new LinkedHashSet<>(); if (file.isFile() && file.getName().endsWith(".jar")) { try (JarFile jar = new JarFile(file)) { // Fast return if the base structure is not there if (jar.getEntry(WEBJAR_LOCATION) == null) { return false; } Enumeration<JarEntry> entries = jar.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); Matcher matcher = WEBJAR_REGEX.matcher(entry.getName()); if (matcher.matches()) { found.add(matcher.group(1) + "-" + matcher.group(2)); } } } catch (IOException e) { log.error("Cannot check if the file " + file.getName() + " is a webjar, cannot open it", e); return false; } for (String lib : found) { log.info("Web Library found in " + file.getName() + " : " + lib); } return !found.isEmpty(); } return false; }
From source file:com.espertech.esper.pattern.EvalNodeUtil.java
/** * Returns all child nodes as a set.// w ww.ja v a 2s . com * @param currentNode parent node * @return all child nodes */ public static Set<EvalFactoryNode> recursiveGetChildNodes(EvalFactoryNode currentNode, EvalNodeUtilFactoryFilter filter) { Set<EvalFactoryNode> result = new LinkedHashSet<EvalFactoryNode>(); if (filter.consider(currentNode)) { result.add(currentNode); } recursiveGetChildNodes(result, currentNode, filter); return result; }
From source file:com.qwazr.externalizor.SimpleCollection.java
public SimpleCollection() { nullList = null;/*from ww w . j av a2 s. c o m*/ stringList = new ArrayList<>(); for (int i = 0; i < RandomUtils.nextInt(5, 50); i++) stringList.add(RandomStringUtils.randomAscii(8)); nullSet = null; integerSet = new LinkedHashSet<>(); for (int i = 0; i < RandomUtils.nextInt(5, 50); i++) integerSet.add(RandomUtils.nextInt()); byteList = new Vector<>(); for (int i = 0; i < RandomUtils.nextInt(5, 50); i++) byteList.add((byte) RandomUtils.nextInt(0, 128)); nullMap = null; mapShortLong = new HashMap<>(); for (int i = 0; i < RandomUtils.nextInt(5, 50); i++) mapShortLong.put((short) RandomUtils.nextInt(0, Short.MAX_VALUE), RandomUtils.nextLong()); }