Example usage for com.google.common.collect Range closedOpen

List of usage examples for com.google.common.collect Range closedOpen

Introduction

In this page you can find the example usage for com.google.common.collect Range closedOpen.

Prototype

public static <C extends Comparable<?>> Range<C> closedOpen(C lower, C upper) 

Source Link

Document

Returns a range that contains all values greater than or equal to lower and strictly less than upper .

Usage

From source file:it.units.malelab.ege.ge.operator.BitsSGECrossover.java

@Override
public List<BitsGenotype> apply(List<BitsGenotype> parents, Random random) {
    BitsGenotype parent1 = parents.get(0);
    BitsGenotype parent2 = parents.get(1);
    if (Math.min(parent1.size(), parent2.size()) < overallSize) {
        //should be an exception
        return parents;
    }/*  w w  w. ja  v a2  s  . c  om*/
    int nonTerminalIndex = random.nextInt(nonTerminalSizes.size());
    List<BitsGenotype> parent1Slices = parent1
            .slices(Utils.slices(Range.closedOpen(0, parent1.size()), nonTerminalSizes));
    List<BitsGenotype> parent2Slices = parent2
            .slices(Utils.slices(Range.closedOpen(0, parent2.size()), nonTerminalSizes));
    BitsGenotype child1 = new BitsGenotype(0);
    BitsGenotype child2 = new BitsGenotype(0);
    for (int i = 0; i < parent1Slices.size(); i++) {
        child1 = child1.append(((i == nonTerminalIndex) ? parent2Slices : parent1Slices).get(i));
        child2 = child2.append(((i == nonTerminalIndex) ? parent1Slices : parent2Slices).get(i));
    }
    return Arrays.asList(child1, child2);
}

From source file:com.github.fge.grappa.buffers.LineCounter.java

public LineCounter(CharSequence input) {
    int lowerBound = 0;
    int index = 0;
    len = input.length();//from   ww w  .  j a v  a 2 s  .  c o  m

    while (index < len) {
        if (input.charAt(index++) != '\n')
            continue;
        lines.add(Range.closedOpen(lowerBound, index));
        lowerBound = index;
    }
    lines.add(Range.closedOpen(lowerBound, index));
    nrLines = lines.size();
}

From source file:com.github.parboiled1.grappa.backport.buffers.LineCounter.java

public LineCounter(final CharSequence input) {
    int lowerBound = 0;
    int index = 0;
    len = input.length();/*  ww w. ja v  a2s  . co m*/

    while (index < len) {
        if (input.charAt(index++) != '\n')
            continue;
        lines.add(Range.closedOpen(lowerBound, index));
        lowerBound = index;
    }
    lines.add(Range.closedOpen(lowerBound, index));
    nrLines = lines.size();
}

From source file:org.robotframework.ide.eclipse.main.plugin.project.build.validation.versiondependent.variables.ScalarAsListValidator.java

@Override
protected Range<RobotVersion> getApplicableVersionRange() {
    return Range.closedOpen(new RobotVersion(2, 8), new RobotVersion(2, 9));
}

From source file:com.metamx.druid.master.rules.SizeLoadRule.java

@JsonCreator
public SizeLoadRule(@JsonProperty("low") long low, @JsonProperty("high") long high,
        @JsonProperty("replicants") Integer replicants, @JsonProperty("tier") String tier) {
    this.low = low;
    this.high = high;
    this.replicants = replicants;
    this.tier = tier;
    this.range = Range.closedOpen(low, high);
}

From source file:com.google.googlejavaformat.java.ModifierOrderer.java

/** Reorders all modifiers in the given text to be in JLS order. */
static JavaInput reorderModifiers(String text) throws FormatterException {
    return reorderModifiers(new JavaInput(text), ImmutableList.of(Range.closedOpen(0, text.length())));
}

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.
 *//* www  . j  a  v a 2  s.  co  m*/
@VisibleForTesting
public SanitizedConfiguration(IJobConfiguration sanitized) {
    this.sanitized = sanitized;
    this.instanceIds = ContiguousSet.create(Range.closedOpen(0, sanitized.getInstanceCount()),
            DiscreteDomain.integers());
}

From source file:com.google.googlejavaformat.java.SnippetFormatter.java

private static Range<Integer> offsetRange(Range<Integer> range, int offset) {
    range = range.canonical(DiscreteDomain.integers());
    return Range.closedOpen(range.lowerEndpoint() + offset, range.upperEndpoint() + offset);
}

From source file:it.units.malelab.ege.ge.mapper.BitsSGEMapper.java

public BitsSGEMapper(int maxDepth, Grammar<T> grammar) {
    super(grammar);
    this.maxDepth = maxDepth;
    nonRecursiveGrammar = Utils.resolveRecursiveGrammar(grammar, maxDepth);
    Map<Pair<T, Integer>, Range<Integer>> codonsRangesMap = new LinkedHashMap<>();
    int startingIndex = 0;
    for (Pair<T, Integer> p : nonRecursiveGrammar.getRules().keySet()) {
        int maximumExpansions = maximumExpansions(p, nonRecursiveGrammar);
        codonsRangesMap.put(p, Range.closedOpen(startingIndex, startingIndex + maximumExpansions));
        startingIndex = startingIndex + maximumExpansions;
    }//w w w .j  av  a2 s .  co m
    nonTerminals = new ArrayList<>(codonsRangesMap.keySet());
    nonTerminalSizes = new ArrayList<>();
    nonTerminalCodonsNumbers = new ArrayList<>();
    overallSize = 0;
    for (Pair<T, Integer> nonTerminal : nonTerminals) {
        Range<Integer> range = codonsRangesMap.get(nonTerminal);
        int nonTerminalCodonsNumber = range.upperEndpoint() - range.lowerEndpoint();
        int codonSize = (int) Math.max(
                Math.ceil(Math.log10(nonRecursiveGrammar.getRules().get(nonTerminal).size()) / Math.log10(2)),
                1);
        nonTerminalSizes.add(nonTerminalCodonsNumber * codonSize);
        nonTerminalCodonsNumbers.add(nonTerminalCodonsNumber);
        overallSize = overallSize + nonTerminalCodonsNumber * codonSize;
    }
}

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./*from   ww w. j  a  va  2  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()));
}