Example usage for com.google.common.collect ContiguousSet create

List of usage examples for com.google.common.collect ContiguousSet create

Introduction

In this page you can find the example usage for com.google.common.collect ContiguousSet create.

Prototype

public static <C extends Comparable> ContiguousSet<C> create(Range<C> range, DiscreteDomain<C> domain) 

Source Link

Document

Returns a ContiguousSet containing the same values in the given domain Range#contains contained by the range.

Usage

From source file:org.nickelproject.util.sources.Sequences.java

public static Source<Integer> integer(final int min, final int max) {
    return Sources.from(ContiguousSet.create(Range.closedOpen(min, max), DiscreteDomain.integers()));
}

From source file:sf.net.experimaestro.utils.RangeUtils.java

/**
 * Transforms a range into an array of {@linkplain Integer}
 *///w w w  . ja  v a2 s .c o m
public static Integer[] toIntegerArray(Range<Integer> closed) {
    ContiguousSet<Integer> integers = ContiguousSet.create(closed, DiscreteDomain.integers());
    return integers.toArray(new Integer[integers.size()]);
}

From source file:com.stackframe.base.Numbers.java

private static Set<Number> positiveIntegers() {
    // Consider adding BigInteger and other subclasses of Number that are integers.
    Set<? extends Number> longKeys = ContiguousSet.create(Range.greaterThan(0L), DiscreteDomain.longs());
    Set<? extends Number> intKeys = ContiguousSet.create(Range.greaterThan(0), DiscreteDomain.integers());
    return Sets.union(longKeys, intKeys);
}

From source file:org.apache.aurora.scheduler.cron.quartz.Quartz.java

/**
 * Convert an Aurora CrontabEntry to a Quartz CronExpression.
 *//*from  ww  w.j av a2s.c o  m*/
static CronExpression cronExpression(CrontabEntry entry, TimeZone timeZone) {
    String dayOfMonth;
    if (entry.hasWildcardDayOfMonth()) {
        dayOfMonth = "?"; // special quartz token meaning "don't care"
    } else {
        dayOfMonth = entry.getDayOfMonthAsString();
    }
    String dayOfWeek;
    if (entry.hasWildcardDayOfWeek() && !entry.hasWildcardDayOfMonth()) {
        dayOfWeek = "?";
    } else {
        List<Integer> daysOfWeek = Lists.newArrayList();
        for (Range<Integer> range : entry.getDayOfWeek().asRanges()) {
            for (int i : ContiguousSet.create(range, DiscreteDomain.integers())) {
                daysOfWeek.add(i + 1); // Quartz has an off-by-one with what the "standard" defines.
            }
        }
        dayOfWeek = Joiner.on(",").join(daysOfWeek);
    }

    String rawCronExpresion = String.join(" ", "0", entry.getMinuteAsString(), entry.getHourAsString(),
            dayOfMonth, entry.getMonthAsString(), dayOfWeek);
    CronExpression cronExpression;
    try {
        cronExpression = new CronExpression(rawCronExpresion);
    } catch (ParseException e) {
        throw new RuntimeException(e);
    }
    cronExpression.setTimeZone(timeZone);
    return cronExpression;
}

From source file:ai.grakn.graql.internal.gremlin.spanningtree.graph.DenseWeightedGraph.java

public static DenseWeightedGraph<Integer> from(double[][] weights) {
    final Set<Integer> nodes = ContiguousSet.create(closedOpen(0, weights.length), integers());
    return DenseWeightedGraph.from(nodes, weights);
}

From source file:org.sonar.java.filters.AnyRuleIssueFilter.java

private static Set<Integer> filteredLines(Tree tree) {
    SyntaxToken firstSyntaxToken = tree.firstToken();
    SyntaxToken lastSyntaxToken = tree.lastToken();
    if (firstSyntaxToken != null && lastSyntaxToken != null) {
        return ContiguousSet.create(Range.closed(firstSyntaxToken.line(), lastSyntaxToken.line()),
                DiscreteDomain.integers());
    }/*  w  ww.  ja v  a  2s . c o m*/
    return new HashSet<>();
}

From source file:com.comphenix.protocol.compat.guava.Guava17.java

@Override
public Set<Integer> toSet(Range<Integer> range) {
    return ContiguousSet.create(range, DiscreteDomain.integers());
}

From source file:org.apache.aurora.scheduler.configuration.SanitizedConfiguration.java

/**
 * Constructs a SanitizedConfiguration object and populates the set of instance IDs for
 * the provided {@link org.apache.aurora.scheduler.storage.entities.ITaskConfig}.
 *
 * @param sanitized A sanitized configuration.
 *//* w w w  . j a v  a2s . c  o m*/
@VisibleForTesting
public SanitizedConfiguration(IJobConfiguration sanitized) {
    this.sanitized = sanitized;
    this.instanceIds = ContiguousSet.create(Range.closedOpen(0, sanitized.getInstanceCount()),
            DiscreteDomain.integers());
}

From source file:com.twitter.aurora.scheduler.configuration.SanitizedConfiguration.java

/**
 * Constructs a SanitizedConfiguration object and populates the set of {@link ITaskConfig}s for
 * the provided config.//  w  w w  .j a  va2  s  .c  o m
 *
 * @param sanitized A sanitized configuration.
 */
@VisibleForTesting
public SanitizedConfiguration(IJobConfiguration sanitized) {
    this.sanitized = sanitized;
    this.tasks = Maps.toMap(
            ContiguousSet.create(Range.closedOpen(0, sanitized.getInstanceCount()), DiscreteDomain.integers()),
            Functions.constant(sanitized.getTaskConfig()));
}

From source file:org.jetbrains.android.dom.converters.TargetApiConverter.java

public TargetApiConverter() {
    Range<Integer> range = Range.closed(1, HIGHEST_KNOWN_API);
    myAllVariants = ContiguousSet.create(range, DiscreteDomain.integers());
}