List of usage examples for com.google.common.collect Sets newTreeSet
public static <E extends Comparable> TreeSet<E> newTreeSet()
From source file:edu.harvard.med.screensaver.ui.arch.util.converter.EmptyWellsConverter.java
private Set<Integer> getFullRows(Set<WellName> wellNames) { int[] rowCounts = new int[ScreensaverConstants.DEFAULT_PLATE_SIZE.getRows()]; Arrays.fill(rowCounts, 0, rowCounts.length, 0); for (WellName wellName : wellNames) { rowCounts[wellName.getRowIndex()]++; }/* w w w . jav a2 s . co m*/ SortedSet<Integer> fullRowIndexes = Sets.newTreeSet(); for (int rowIndex = 0; rowIndex < rowCounts.length; ++rowIndex) { if (rowCounts[rowIndex] == ScreensaverConstants.DEFAULT_PLATE_SIZE.getColumns()) { fullRowIndexes.add(rowIndex); } } return fullRowIndexes; }
From source file:org.n52.svalbard.encode.AbstractRectifiedGridCoverageTypeEncoder.java
private List<String> getUoms(List<ComparableValue<?, ?>> domainSet) { SortedSet<String> uoms = Sets.newTreeSet(); for (ComparableValue<?, ?> values : domainSet) { uoms.add(values.getUnit());// www . j a v a2s. co m } return Lists.newArrayList(uoms); }
From source file:edu.harvard.med.screensaver.ui.libraries.LibraryCopyPlateCommentSearchResults.java
private void initialize(Collection<Plate> plates) { SortedSet<PlateActivity> comments = Sets.newTreeSet(); for (Plate plate : plates) { //plate = _dao.reloadEntity(plate); for (AdministrativeActivity ae : plate.getUpdateActivitiesOfType(AdministrativeActivityType.COMMENT)) { comments.add(new PlateActivity(plate, ae)); }/*from ww w . jav a 2 s .co m*/ } initialize(new InMemoryDataModel<PlateActivity>(new SetBasedDataFetcher<PlateActivity, Integer>(comments))); }
From source file:org.gradoop.model.impl.id.GradoopIdSet.java
@Override public void readFields(DataInput dataInput) throws IOException { int count = dataInput.readInt(); identifiers = Sets.newTreeSet(); for (int i = 0; i < count; i++) { GradoopId id = new GradoopId(); id.readFields(dataInput);// www. j ava2 s .c o m identifiers.add(id); } }
From source file:org.sonar.duplications.algorithm.filter.IntervalTree.java
/** * Get center/median point from all intervals start and end points * * @param intervalList list of intervals to look at * @return the median of the set// ww w . ja va2 s .c o m */ private int getMedian(List<Interval<T>> intervalList) { SortedSet<Integer> endpoints = Sets.newTreeSet(); for (Interval<T> interval : intervalList) { endpoints.add(interval.getStart()); endpoints.add(interval.getEnd()); } int i = 0; int middle = endpoints.size() / 2; int median = 0; for (int point : endpoints) { if (i == middle) { median = point; break; } i++; } return median; }
From source file:co.mitro.core.server.data.DBHistoricalUserState.java
public Set<Integer> getSecretIds() { Set<Integer> secretIds = Sets.newTreeSet(); for (Secret s : secrets) { secretIds.add(s.secretId);/*from w ww.j a va 2s. c o m*/ } return secretIds; }
From source file:de.tuberlin.uebb.jdae.transformation.Causalisation.java
private final void collectBlocks(final Matching matching, final Comparator<IntPair> comp, final IntPair componentStart, final Iterator<IntPair> k) { final Set<GlobalVariable> blockVars = Sets.newTreeSet(); final TIntObjectMap<Range<Integer>> blockEqns = new TIntObjectHashMap<>(); collectEquation(matching, componentStart, blockVars, blockEqns); IntPair eqNext = null;/* w w w.jav a 2 s. c o m*/ while (k.hasNext() && (comp.compare(componentStart, (eqNext = k.next())) == 0)) { collectEquation(matching, eqNext, blockVars, blockEqns); eqNext = null; } logger.log(Level.INFO, "Simulation block of {0} equation(s) computing {1}", new Object[] { blockEqns.size(), blockVars }); computations.add(blockEqns); iteratees.add(blockVars); if (eqNext != null) collectBlocks(matching, comp, eqNext, k); }
From source file:com.netflix.ice.basic.BasicTagGroupManager.java
private Collection<Long> getMonthMillis(Interval interval) { Set<Long> result = Sets.newTreeSet(); for (Long milli : tagGroups.keySet()) { DateTime monthDate = new DateTime(milli, DateTimeZone.UTC); if (new Interval(monthDate, monthDate.plusMonths(1)).overlap(interval) != null) result.add(milli);// w w w.j av a 2s. c om } return result; }
From source file:eu.project.ttc.engines.ScorerAE.java
@Override public void collectionProcessComplete() throws AnalysisEngineProcessException { logger.info("Scorying terms for TermIndex {}", this.termIndexResource.getTermIndex().getName()); TermIndex termIndex = termIndexResource.getTermIndex(); VariantScorerConfig defaultScorerConfig = termIndex.getLang().getScorerConfig(); TermVariationScorer variantScorer = new TermVariationScorer(defaultScorerConfig); /*//from w w w. j av a 2s . co m * 1- compute scores */ logger.debug("Scorying"); variantScorer.setHistory(historyResource.getHistory()); ScoredModel scoredModel = variantScorer.score(termIndex); /* * 2- remove filtered terms */ logger.debug("Selecting terms for removal"); Set<Term> keptTerms = Sets.newHashSet(); for (ScoredTerm st : scoredModel.getTerms()) keptTerms.add(st.getTerm()); Set<Term> remTerms = Sets.newHashSet(); int size = termIndex.getTerms().size(); for (Term t : termIndex.getTerms()) if (!keptTerms.contains(t)) remTerms.add(t); logger.debug("Removing filtered terms"); if (taskObserver.isPresent()) taskObserver.get().setTotalTaskWork(remTerms.size()); for (Term t : remTerms) { if (taskObserver.isPresent()) taskObserver.get().work(1); termIndex.removeTerm(t); } logger.debug("{} terms filtered (and removed from term index) out of {}", remTerms.size(), size); /* * 3- reset the sorted variations and unique bases */ logger.debug("Resetting scored variations and unique bases"); for (ScoredTerm st : scoredModel.getTerms()) { TreeSet<TermVariation> sortedVariations = Sets.newTreeSet(); for (ScoredVariation sv : st.getVariations()) { TermVariation termVariation = sv.getTermVariation(); /* * Add this term variation to the variants */ termVariation.setScore(sv.getVariationScore()); sortedVariations.add(termVariation); /* * Set this term variation as the unique base for the variant */ TreeSet<TermVariation> base = Sets.newTreeSet(); base.add(termVariation); termVariation.getVariant().setBases(base); } /* * Set the sorted set as the variants */ st.getTerm().setVariations(sortedVariations); } }
From source file:com.eucalyptus.webui.server.VmTypeWebBackend.java
/** * Update VmType by UI input./*from w ww . j ava 2 s .c om*/ * * @param row * @throws EucalyptusServiceException */ public static void setVmType(SearchResultRow row) throws EucalyptusServiceException { VmType input = deserializeVmType(row); if (input == null) { throw new EucalyptusServiceException("Invalid input"); } Set<VmType> newVms = Sets.newTreeSet(); for (VmType v : VmTypes.list()) { if (v.getName().equals(input.getName())) { newVms.add(input); } else { newVms.add(v); } } try { VmTypes.update(newVms); } catch (EucalyptusCloudException e) { LOG.error("Failed to update VmType for row " + row, e); throw new EucalyptusServiceException(e.getMessage(), e); } }