List of usage examples for com.google.common.collect Sets newTreeSet
public static <E> TreeSet<E> newTreeSet(Comparator<? super E> comparator)
From source file:edu.harvard.med.screensaver.model.libraries.LibraryPlate.java
public LibraryPlate(Integer plateNumber, Library library, Set<AssayPlate> assayPlates) { super(plateNumber); _library = library;/*from w w w.j ava 2s . c o m*/ _assayPlateCount = assayPlates.size(); Iterable<AssayPlate> assayPlatesUniqueAttempts = Iterables.filter(assayPlates, AssayPlate.IsFirstReplicate); _copiesScreened = Sets .newTreeSet(Iterables.transform(Iterables.filter(assayPlates, AssayPlate.HasLibraryScreening), Functions.compose(Plate.ToCopy, AssayPlate.ToPlate))); _libraryScreenings = Sets.newTreeSet( Iterables.filter(Iterables.transform(assayPlatesUniqueAttempts, AssayPlate.ToLibraryScreening), Predicates.notNull())); if (!_libraryScreenings.isEmpty()) { _firstDateScreened = _libraryScreenings.first().getDateOfActivity(); _lastDateScreened = _libraryScreenings.last().getDateOfActivity(); } SortedSet<AdministrativeActivity> dataLoadings = Sets.newTreeSet(Iterables.filter( Iterables.transform(assayPlatesUniqueAttempts, AssayPlate.ToScreenResultDataLoading), Predicates.notNull())); _dataLoadingCount = dataLoadings.size(); if (_dataLoadingCount > 0) { _firstDateDataLoaded = dataLoadings.first().getDateOfActivity(); _lastDateDataLoaded = dataLoadings.last().getDateOfActivity(); } }
From source file:com.palantir.atlasdb.keyvalue.partition.util.PartitionedRangedIterator.java
public PartitionedRangedIterator(Collection<ConsistentRingRangeRequest> ranges) { this.ranges = Sets.newTreeSet(ConsistentRingRangeRequests.getCompareByStartRow()); this.ranges.addAll(ranges); this.currentRange = ranges.iterator(); this.currentRangeIterators = ImmutableSet.of(); }
From source file:co.cask.cdap.data2.dataset2.lib.table.inmemory.InMemoryScanner.java
public InMemoryScanner(Iterator<Map.Entry<byte[], NavigableMap<byte[], byte[]>>> rows, FuzzyRowFilter filter, byte[][] columnsToInclude) { this.rows = rows; this.filter = filter; if (columnsToInclude != null) { this.columnsToInclude = Sets.newTreeSet(Bytes.BYTES_COMPARATOR); Collections.addAll(this.columnsToInclude, columnsToInclude); } else {//from w ww. jav a2s. c o m this.columnsToInclude = null; } }
From source file:org.apache.crunch.impl.mr.plan.Edge.java
Edge(Vertex head, Vertex tail) { this.head = head; this.tail = tail; this.paths = Sets.newTreeSet(NODE_CMP); }
From source file:org.opentestsystem.shared.progman.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); }/* www . j a v a 2 s . c om*/ this.tenants = setWithComparator; }
From source file:org.gradle.tooling.internal.gradle.DefaultGradleTask.java
public SortedSet<String> getTaskNames() { // TODO use comparator SortedSet result = Sets.newTreeSet(new TaskNameComparator()); result.add(getPath());/*w w w .j a v a2 s .c om*/ return result; }
From source file:io.druid.segment.indexing.granularity.ArbitraryGranularitySpec.java
@JsonCreator public ArbitraryGranularitySpec(@JsonProperty("queryGranularity") QueryGranularity queryGranularity, @JsonProperty("intervals") List<Interval> inputIntervals) { this.queryGranularity = queryGranularity; this.intervals = Sets.newTreeSet(Comparators.intervalsByStartThenEnd()); if (inputIntervals == null) { inputIntervals = Lists.newArrayList(); }/*from w ww . j a v a 2 s .co m*/ // Insert all intervals for (final Interval inputInterval : inputIntervals) { intervals.add(inputInterval); } // Ensure intervals are non-overlapping (but they may abut each other) final PeekingIterator<Interval> intervalIterator = Iterators.peekingIterator(intervals.iterator()); while (intervalIterator.hasNext()) { final Interval currentInterval = intervalIterator.next(); if (intervalIterator.hasNext()) { final Interval nextInterval = intervalIterator.peek(); if (currentInterval.overlaps(nextInterval)) { throw new IllegalArgumentException( String.format("Overlapping intervals: %s, %s", currentInterval, nextInterval)); } } } }
From source file:org.apache.isis.core.metamodel.layout.memberorderfacet.DeweyOrderSet.java
public static DeweyOrderSet createOrderSet(final List<FacetedMethod> facetedMethods) { final SortedMap<String, SortedSet<FacetedMethod>> sortedMembersByGroup = Maps.newTreeMap(); final SortedSet<FacetedMethod> nonAnnotatedGroup = Sets.newTreeSet(new MemberIdentifierComparator()); // spin over all the members and put them into a Map of SortedSets // any non-annotated members go into additional nonAnnotatedGroup set. for (final FacetedMethod facetedMethod : facetedMethods) { final MemberOrderFacet memberOrder = facetedMethod.getFacet(MemberOrderFacet.class); if (memberOrder == null) { nonAnnotatedGroup.add(facetedMethod); continue; }/* w ww .j av a2s . c om*/ final SortedSet<FacetedMethod> sortedMembersForGroup = getSortedSet(sortedMembersByGroup, memberOrder.name()); sortedMembersForGroup.add(facetedMethod); } // add the non-annotated group to the first "" group. final SortedSet<FacetedMethod> defaultSet = getSortedSet(sortedMembersByGroup, ""); defaultSet.addAll(nonAnnotatedGroup); // create OrderSets, wiring up parents and children. // since sortedMembersByGroup is a SortedMap, the // iteration will be in alphabetical order (ie parent groups before // their children). final Set<String> groupNames = sortedMembersByGroup.keySet(); final SortedMap<String, DeweyOrderSet> orderSetsByGroup = Maps.newTreeMap(); for (final String string : groupNames) { final String groupName = string; final DeweyOrderSet deweyOrderSet = new DeweyOrderSet(groupName); orderSetsByGroup.put(groupName, deweyOrderSet); ensureParentFor(orderSetsByGroup, deweyOrderSet); } // now populate the OrderSets for (final String groupName : groupNames) { final DeweyOrderSet deweyOrderSet = orderSetsByGroup.get(groupName); // REVIEW: something fishy happens here with casting, hence warnings // left in final SortedSet sortedMembers = sortedMembersByGroup.get(groupName); deweyOrderSet.addAll(sortedMembers); deweyOrderSet.copyOverChildren(); } return orderSetsByGroup.get(""); }
From source file:org.incode.module.commchannel.dom.impl.channel.CommunicationChannelRepository.java
@Programmatic public SortedSet<CommunicationChannel> findByOwner(final Object owner) { final List<CommunicationChannelOwnerLink> links = linkRepository.findByOwner(owner); return Sets.newTreeSet( Iterables.transform(links, CommunicationChannelOwnerLink.Functions.communicationChannel())); }
From source file:io.druid.query.search.SearchBinaryFn.java
@Override public Result<SearchResultValue> apply(Result<SearchResultValue> arg1, Result<SearchResultValue> arg2) { if (arg1 == null) { return arg2; }//from w ww .j a v a 2 s . c o m if (arg2 == null) { return arg1; } SearchResultValue arg1Vals = arg1.getValue(); SearchResultValue arg2Vals = arg2.getValue(); TreeSet<SearchHit> results = Sets.newTreeSet(searchSortSpec.getComparator()); results.addAll(Lists.newArrayList(arg1Vals)); results.addAll(Lists.newArrayList(arg2Vals)); return (gran instanceof AllGranularity) ? new Result<SearchResultValue>(arg1.getTimestamp(), new SearchResultValue(Lists.newArrayList(Iterables.limit(results, limit)))) : new Result<SearchResultValue>(gran.toDateTime(gran.truncate(arg1.getTimestamp().getMillis())), new SearchResultValue(Lists.newArrayList(results))); }