List of usage examples for java.util TreeSet addAll
public boolean addAll(Collection<? extends E> c)
From source file:esg.node.filters.MountedPathResolver.java
public void addMountPoints(Map<String, String> readMountpoints) { this.mountPoints.clear(); Comparator<? super String> stringLengthComparator = new Comparator<String>() { public int compare(String o1, String o2) { if (o1.length() >= o2.length()) { return -1; } else { return 1; }//from ww w. ja v a 2 s .c o m } }; //Just sort the keys in length order. TreeSet<String> rmpSorted = new TreeSet<String>(stringLengthComparator); rmpSorted.addAll(readMountpoints.keySet()); for (String key : rmpSorted) { addMountPoint(key, readMountpoints.get(key)); } }
From source file:net.certiv.authmgr.task.section.model.AnalyzeModel.java
private void analyzePartitions(PersistantWordsDataSource pds, String category, HashMap<String, HashMap<String, WordProbabilityPT>> partsMap) { PartitionKeyComparator keyComp = new PartitionKeyComparator(partsMap); TreeSet<String> partKeys = new TreeSet<String>(keyComp); partKeys.addAll(partsMap.keySet()); String partitions = ""; for (Iterator<String> it = partKeys.iterator(); it.hasNext();) { partitions = partitions + it.next() + " "; }/*w w w .ja va 2s .c om*/ Log.info(this, "Partition collection: " + partKeys.size() + " = " + partitions); // for each partition for (Iterator<String> it = partKeys.iterator(); it.hasNext();) { String partition = it.next(); HashMap<String, WordProbabilityPT> wordsMap = partsMap.get(partition); analyzeWords(category, partition, wordsMap); } }
From source file:edu.wisc.doit.tcrypt.controller.EncryptController.java
@RequestMapping(value = "/encryptionServices", method = RequestMethod.GET) public @ResponseBody Set<String> getServiceNamesInJSON() { final TreeSet<String> serviceNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); serviceNames.addAll(keysKeeper.getListOfServiceNames()); return serviceNames; }
From source file:org.opentestsystem.shared.progman.client.domain.TenantChain.java
public void setTenants(final Set<Tenant> inTenants) { // To ensure resting state of tenants are in order. final TreeSet<Tenant> setWithComparator = Sets.newTreeSet(new ReverseTenantComparator()); if (inTenants != null) { setWithComparator.addAll(inTenants); }// ww w . j av a2 s. co m this.tenants = setWithComparator; }
From source file:com.linkedin.pinot.operator.OrOperatorTest.java
@Test public void testIntersectionForThreeLists() { int[] list1 = new int[] { 2, 3, 6, 10, 15, 16, 28 }; int[] list2 = new int[] { 3, 6, 8, 20, 28 }; int[] list3 = new int[] { 1, 2, 3, 6, 30 }; List<Operator> operators = new ArrayList<Operator>(); operators.add(makeFilterOperator(list1)); operators.add(makeFilterOperator(list2)); operators.add(makeFilterOperator(list3)); final OrOperator orOperator = new OrOperator(operators); orOperator.open();/*from w w w.ja v a 2 s.com*/ Block block; TreeSet<Integer> set = new TreeSet<Integer>(); set.addAll(Lists.newArrayList(ArrayUtils.toObject(list1))); set.addAll(Lists.newArrayList(ArrayUtils.toObject(list2))); set.addAll(Lists.newArrayList(ArrayUtils.toObject(list3))); Iterator<Integer> expectedIterator = set.iterator(); while ((block = orOperator.nextBlock()) != null) { final BlockDocIdSet blockDocIdSet = block.getBlockDocIdSet(); final BlockDocIdIterator iterator = blockDocIdSet.iterator(); int docId; while ((docId = iterator.next()) != Constants.EOF) { Assert.assertEquals(expectedIterator.next().intValue(), docId); } } orOperator.close(); }
From source file:therian.OperatorsTest.java
@Test public void testComparatorComplex() { final ArrayList<Operator<?>> expected = new ArrayList<Operator<?>>(); expected.add(new AppendixSurgeon()); expected.add(new TonsilSurgeon()); expected.add(new MasterSurgeon()); expected.add(new SuccessOperator()); expected.add(new ELCoercionConverter()); expected.add(new DefaultImmutableChecker()); final TreeSet<Operator<?>> actual = new TreeSet<Operator<?>>(Operators.comparator()); actual.addAll(expected); assertEquals(expected, new ArrayList<Operator<?>>(actual)); }
From source file:com.linkedin.pinot.operator.OrOperatorTest.java
@Test public void testComplex() { int[] list1 = new int[] { 2, 3, 6, 10, 15, 16, 28 }; int[] list2 = new int[] { 3, 6, 8, 20, 28 }; int[] list3 = new int[] { 1, 2, 3, 6, 30 }; TreeSet<Integer> set = new TreeSet<Integer>(); set.addAll(Lists.newArrayList(ArrayUtils.toObject(list1))); set.addAll(Lists.newArrayList(ArrayUtils.toObject(list2))); set.addAll(Lists.newArrayList(ArrayUtils.toObject(list3))); Iterator<Integer> expectedIterator = set.iterator(); List<Operator> operators = new ArrayList<Operator>(); operators.add(makeFilterOperator(list1)); operators.add(makeFilterOperator(list2)); final OrOperator orOperator1 = new OrOperator(operators); List<Operator> operators1 = new ArrayList<Operator>(); operators1.add(orOperator1);/* w w w . j a v a 2s.c om*/ operators1.add(makeFilterOperator(list3)); final OrOperator orOperator = new OrOperator(operators1); orOperator.open(); BaseFilterBlock block; while ((block = orOperator.getNextBlock()) != null) { final BlockDocIdSet blockDocIdSet = block.getBlockDocIdSet(); final BlockDocIdIterator iterator = blockDocIdSet.iterator(); int docId; while ((docId = iterator.next()) != Constants.EOF) { System.out.println(docId); Assert.assertEquals(expectedIterator.next().intValue(), docId); } } orOperator.close(); }
From source file:tvbrowser.ui.settings.looksSettings.SkinLNFSettings.java
private String[] getThemePacks() { final TreeSet<String> themepacks = new TreeSet<String>(); themepacks.addAll(Arrays.asList(getThemePacks(new File("themepacks")))); themepacks.addAll(Arrays.asList(getThemePacks(new File(Settings.getUserDirectoryName(), "themepacks")))); if (OperatingSystem.isMacOs()) { themepacks.addAll(/* w ww . j a v a2 s .c o m*/ Arrays.asList(getThemePacks(new File(Settings.getOSLibraryDirectoryName() + "themepacks")))); } return themepacks.toArray(new String[themepacks.size()]); }
From source file:net.certiv.authmgr.task.section.model.AnalyzeModel.java
private void analyzeWords(String category, String partition, HashMap<String, WordProbabilityPT> wordsMap) { // convert to sorted set WordProbPTComparator sorter = new WordProbPTComparator(); TreeSet<WordProbabilityPT> wordProbs = new TreeSet<WordProbabilityPT>(sorter); wordProbs.addAll(wordsMap.values()); // now accumulate and print statistics StringBuffer wordlist = new StringBuffer(); int k = 0;//from w w w .ja v a 2 s . c o m for (Iterator<WordProbabilityPT> it = wordProbs.iterator(); it.hasNext() && k < 20; k++) { WordProbabilityPT wp = it.next(); String word = wp.getWord(); double prob = wp.getProbability(); double count = wp.getMatchingCount(); BigDecimal probBD = new BigDecimal(prob).setScale(8, BigDecimal.ROUND_HALF_UP); String countStr = Util.rightAlign("" + count, 6); String wordAbbr = StringUtils.abbreviate(word, 13); wordlist.append(Util.leftAlign(wordAbbr, 14) + probBD + "/" + countStr + "| "); } Log.info(this, Util.leftAlign(partition + ":", 14) + Util.rightAlign("" + wordProbs.size(), 5) + " = " + wordlist.toString()); }
From source file:gov.nih.nci.caarray.application.translation.magetab.TermSourceTranslator.java
/** * @param matches//from w w w . j a va 2 s .com * @return */ private TermSource getBestMatch(Set<TermSource> matches) { TreeSet<TermSource> sorted = new TreeSet<TermSource>(new TermSourceVersionComparator()); sorted.addAll(matches); return sorted.first(); }