List of usage examples for java.util Set size
int size();
From source file:eu.itesla_project.modules.rules.CheckSecurityTool.java
private static void prettyPrint( Map<String, Map<SecurityIndexType, SecurityRuleCheckStatus>> checkStatusPerContingency, Set<SecurityIndexType> securityIndexTypes) { Table table = new Table(1 + securityIndexTypes.size(), BorderStyle.CLASSIC_WIDE); table.addCell("Contingency"); for (SecurityIndexType securityIndexType : securityIndexTypes) { table.addCell(securityIndexType.toString()); }//ww w . j a v a 2 s.c o m for (Map.Entry<String, Map<SecurityIndexType, SecurityRuleCheckStatus>> entry : checkStatusPerContingency .entrySet()) { String contingencyId = entry.getKey(); Map<SecurityIndexType, SecurityRuleCheckStatus> checkStatus = entry.getValue(); table.addCell(contingencyId); for (SecurityIndexType securityIndexType : securityIndexTypes) { table.addCell(checkStatus.get(securityIndexType).name()); } } System.out.println(table.render()); }
From source file:com.adaptris.core.marshaller.xstream.XStreamUtils.java
/** * Determine if the given Set <code>toCheck</code> contains any of the elements within <code>possibles</code> * /* w w w. j a v a2 s.c om*/ * @param toCheck - Set of Strings to check * @param possibles - Collection of * @return true if the set contains the possibles. */ public static boolean setContainsAnyOf(Set<String> toCheck, Collection<String> possibles) { Set<String> copy = new HashSet<String>(toCheck); copy.retainAll(possibles); return copy.size() > 0; }
From source file:com.microsoft.tfs.core.util.CodePageData.java
/** * Gets the array of code pages that are configured and can be mapped to a * charset/* ww w . j a v a2 s . co m*/ * * @return the code pages that can be resolved to charsets */ static Integer[] getCodePages() { synchronized (lock) { if (!initialized) { initialize(); } final Set codePageSet = codePageToCharsetNames.keySet(); return (Integer[]) codePageSet.toArray(new Integer[codePageSet.size()]); } }
From source file:net.sourceforge.fenixedu.domain.onlineTests.StudentTestQuestion.java
public static boolean hasStudentTestQuestions(final Registration registration, final DistributedTest distributedTest) { Set<StudentTestQuestion> studentTestQuestions = findStudentTestQuestions(registration, distributedTest); return (studentTestQuestions == null || studentTestQuestions.size() == 0) ? false : true; }
From source file:Main.java
/** * @param orig/* w ww . j a v a 2 s. co m*/ * if null, return intersect */ public static Set<? extends Object> intersectSet(Set<? extends Object> orig, Set<? extends Object> intersect) { if (orig == null) return intersect; if (intersect == null || orig.isEmpty()) return Collections.emptySet(); Set<Object> set = new HashSet<Object>(orig.size()); for (Object p : orig) { if (intersect.contains(p)) set.add(p); } return set; }
From source file:com.redhat.rcm.version.testutil.TestProjectFixture.java
public static Set<Model> loadModels(final Set<File> poms) throws VManException, IOException { final Set<Model> models = new LinkedHashSet<Model>(poms.size()); for (final File pom : poms) { models.add(loadModel(pom));//w w w . j a v a2s . c o m } return models; }
From source file:com.microsoft.tfs.core.util.CodePageData.java
/** * Gets the array of charset names that are configured and can be mapped to * a code page./*from w ww. j av a2s.com*/ * * @return the charset names that can be resolved to code pages */ static String[] getCharsetNames() { synchronized (lock) { if (!initialized) { initialize(); } final Set charsetNameSet = charsetNameToCodePage.keySet(); return (String[]) charsetNameSet.toArray(new String[charsetNameSet.size()]); } }
From source file:io.cortical.retina.model.TestDataHarness.java
/** * Create dummy {@link Fingerprint}./*from w ww . ja v a 2 s . c o m*/ * * @return dummy fingerprint. */ public static Fingerprint createFingerprint() { Random random = new Random(SEED); Set<Integer> positionSet = new LinkedHashSet<>(); while (positionSet.size() <= FINGERPRINT_LENGTH) { positionSet.add(random.nextInt(MAX_POSITION)); } Integer[] positionsInteger = new Integer[FINGERPRINT_LENGTH]; positionsInteger = positionSet.toArray(positionsInteger); sort(positionsInteger); return new Fingerprint(ArrayUtils.toPrimitive(positionsInteger)); }
From source file:io.cortical.retina.model.TestDataHarness.java
/** * Create dummy {@link Fingerprint}./*from w ww . j a v a 2 s. c om*/ * @param sparsity percentage of on bits * @return dummy fingerprint. */ public static Fingerprint createFingerprint(double sparsity) { Random random = new Random(SEED); Set<Integer> positionSet = new LinkedHashSet<>(); while (positionSet.size() <= ((double) (MAX_POSITION)) * sparsity) { positionSet.add(random.nextInt(MAX_POSITION)); } Integer[] positionsInteger = new Integer[FINGERPRINT_LENGTH]; positionsInteger = positionSet.toArray(positionsInteger); sort(positionsInteger); return new Fingerprint(ArrayUtils.toPrimitive(positionsInteger)); }
From source file:net.sf.taverna.t2.maven.plugins.Utils.java
public static <T> List<Set<T>> getSubsets(Set<T> set) { List<Set<T>> subsets = new ArrayList<Set<T>>(); List<T> list = new ArrayList<T>(set); int numOfSubsets = 1 << set.size(); for (int i = 0; i < numOfSubsets; i++) { Set<T> subset = new HashSet<T>(); for (int j = 0; j < numOfSubsets; j++) { if (((i >> j) & 1) == 1) { subset.add(list.get(j)); }//w ww. ja v a 2 s. c om } if (!subset.isEmpty()) { subsets.add(subset); } } Collections.sort(subsets, new Comparator<Set<T>>() { @Override public int compare(Set<T> o1, Set<T> o2) { return o1.size() - o2.size(); } }); return subsets; }