List of usage examples for com.google.common.collect ImmutableSortedSet builder
@Deprecated public static <E> ImmutableSortedSet.Builder<E> builder()
From source file:blockplus.model.polyomino.Polyominos.java
private static SortedMap<Integer, Set<Polyomino>> computeRadiusIndexes(final Set<Integer> radius) { final Map<Integer, ImmutableSortedSet.Builder<Polyomino>> tmpMap = Maps.newTreeMap(); for (final Integer integer : radius) tmpMap.put(integer, new ImmutableSortedSet.Builder<Polyomino>(Ordering.natural())); for (final Polyomino polyomino : Polyomino.set()) tmpMap.get(polyomino.radius()).add(polyomino); final Builder<Integer, Set<Polyomino>> builder = new ImmutableSortedMap.Builder<Integer, Set<Polyomino>>( Ordering.natural());/*from ww w . java2 s . c om*/ for (final Entry<Integer, ImmutableSortedSet.Builder<Polyomino>> entry : tmpMap.entrySet()) builder.put(entry.getKey(), entry.getValue().build()); return builder.build(); }
From source file:google.registry.monitoring.metrics.LinearFitter.java
/** * Create a new {@link LinearFitter}./*www. ja v a 2 s.c o m*/ * * @param numFiniteIntervals the number of intervals, excluding the underflow and overflow * intervals * @param width the width of each interval * @param offset the start value of the first interval * @throws IllegalArgumentException if {@code numFiniteIntervals <= 0} or {@code width <= 0} */ public static LinearFitter create(int numFiniteIntervals, double width, double offset) { checkArgument(numFiniteIntervals > 0, "numFiniteIntervals must be greater than 0"); checkArgument(width > 0, "width must be greater than 0"); checkDouble(offset); ImmutableSortedSet.Builder<Double> boundaries = ImmutableSortedSet.naturalOrder(); for (int i = 0; i < numFiniteIntervals + 1; i++) { boundaries.add(width * i + offset); } return new AutoValue_LinearFitter(width, offset, boundaries.build()); }
From source file:google.registry.monitoring.metrics.ExponentialFitter.java
/** * Create a new {@link ExponentialFitter}. * * @param numFiniteIntervals the number of intervals, excluding the underflow and overflow * intervals/*from w w w . ja v a 2 s . co m*/ * @param base the base of the exponent * @param scale a multiplicative factor for the exponential function * @throws IllegalArgumentException if {@code numFiniteIntervals <= 0}, {@code width <= 0} or * {@code base <= 1} */ public static ExponentialFitter create(int numFiniteIntervals, double base, double scale) { checkArgument(numFiniteIntervals > 0, "numFiniteIntervals must be greater than 0"); checkArgument(scale != 0, "scale must not be 0"); checkArgument(base > 1, "base must be greater than 1"); checkDouble(base); checkDouble(scale); ImmutableSortedSet.Builder<Double> boundaries = ImmutableSortedSet.naturalOrder(); for (int i = 0; i < numFiniteIntervals + 1; i++) { boundaries.add(scale * Math.pow(base, i)); } return new AutoValue_ExponentialFitter(base, scale, boundaries.build()); }
From source file:google.registry.rde.RdeResourceType.java
/** Returns set of resource type URIs included in a deposit {@code mode}. */ public static ImmutableSortedSet<String> getUris(RdeMode mode) { ImmutableSortedSet.Builder<String> builder = new ImmutableSortedSet.Builder<>(Ordering.natural()); for (RdeResourceType resourceType : RdeResourceType.values()) { if (resourceType.getModes().contains(mode)) { builder.add(resourceType.getUri()); }// w w w . j av a 2s .co m } return builder.build(); }
From source file:com.proofpoint.configuration.ConfigurationInspector.java
public SortedSet<ConfigRecord<?>> inspect(ConfigurationFactory configurationFactory) { ImmutableSortedSet.Builder<ConfigRecord<?>> builder = ImmutableSortedSet.naturalOrder(); for (Entry<ConfigurationProvider<?>, Object> entry : configurationFactory.getInstanceCache().entrySet()) { ConfigurationProvider<?> configurationProvider = entry.getKey(); builder.add(ConfigRecord.createConfigRecord(configurationProvider)); }//from www . ja v a 2s . c o m return builder.build(); }
From source file:com.stackframe.sarariman.holidays.HolidaysImpl.java
@Override public Iterable<Holiday> getUpcoming() { try (Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement()) { try (ResultSet rs = statement.executeQuery( "SELECT date, description " + "FROM holidays WHERE date >= DATE(NOW()) ORDER BY date")) { ImmutableSortedSet.Builder<Holiday> b = ImmutableSortedSet.naturalOrder(); while (rs.next()) { Date date = rs.getDate("date"); String description = rs.getString("description"); Holiday holiday = new HolidayImpl(date, description); b.add(holiday);//from w w w. j av a 2 s . co m } return b.build(); } } catch (SQLException e) { throw new RuntimeException(e); } }
From source file:org.caleydo.view.bicluster.ScanLZTable.java
@Override public List<FuzzyClustering> call() throws Exception { final int rows = lOrZ.depth(); final int clusters = lOrZ.size(); List<FuzzyClustering> l = new ArrayList<>(clusters); for (int i = 0; i < clusters; ++i) { ImmutableSortedSet.Builder<IntFloat> b = ImmutableSortedSet.orderedBy(IntFloat.BY_MEMBERSHIP); for (int j = 0; j < rows; ++j) { float p = lOrZ.getRaw(i, j); b.add(new IntFloat(j, p)); }//from w w w . ja va 2 s .co m l.add(new FuzzyClustering(b.build())); } return ImmutableList.copyOf(l); }
From source file:io.airlift.configuration.ConfigurationInspector.java
public SortedSet<ConfigRecord<?>> inspect(ConfigurationFactory configurationFactory) { ImmutableSortedSet.Builder<ConfigRecord<?>> builder = ImmutableSortedSet.naturalOrder(); for (ConfigurationProvider<?> configurationProvider : configurationFactory.getConfigurationProviders()) { builder.add(ConfigRecord.createConfigRecord(configurationProvider)); }/* w w w . j ava 2 s . c o m*/ return builder.build(); }
From source file:org.cyclop.common.Gullectors.java
public static <T extends Comparable<?>> Collector<T, ?, ImmutableSortedSet<T>> toNaturalImmutableSortedSet() { Supplier<ImmutableSortedSet.Builder<T>> supplier = ImmutableSortedSet::naturalOrder; BiConsumer<ImmutableSortedSet.Builder<T>, T> accumulator = (b, v) -> b.add(v); BinaryOperator<ImmutableSortedSet.Builder<T>> combiner = (l, r) -> l.addAll(r.build()); Function<ImmutableSortedSet.Builder<T>, ImmutableSortedSet<T>> finisher = ImmutableSortedSet.Builder::build; return Collector.of(supplier, accumulator, combiner, finisher); }
From source file:edu.umn.nlptab.uimatyping.TypeFilterBuilder.java
public ImmutableSet<String> createTypeFilter() { ImmutableSortedSet.Builder<String> acceptedTypesBuilder = ImmutableSortedSet.naturalOrder(); Iterator<Type> typeIterator = typeSystem.getTypeIterator(); while (typeIterator.hasNext()) { Type next = typeIterator.next(); if (typeFilterLists.shouldAcceptType(next, typeSystem)) { acceptedTypesBuilder.add(next.getName()); }// w w w .j ava 2s. co m } return acceptedTypesBuilder.build(); }