List of usage examples for com.google.common.collect Range closedOpen
public static <C extends Comparable<?>> Range<C> closedOpen(C lower, C upper)
From source file:edu.cmu.sv.modelinference.eventtool.classification.EventUtils.java
public static List<Range<Integer>> computeEventSequence(double minX, double maxX, List<Range<Integer>> violations) { LinkedList<Range<Integer>> eventSequence = new LinkedList<>(); int begin = (int) minX; for (Range<Integer> violation : violations) { int endpoint = violation.lowerEndpoint(); eventSequence.add(Range.closedOpen(begin, endpoint)); begin = endpoint;/*from w w w . j a va2 s .c om*/ } eventSequence.add(Range.closedOpen(begin, (int) maxX)); return eventSequence; }
From source file:com.google.errorprone.fixes.Replacement.java
/** * Creates a {@link Replacement}. Start and end positions are represented as code unit indices * in a Unicode 16-bit string./*from w w w. ja v a 2s . c o m*/ * * @param startPosition the beginning of the replacement * @param endPosition the end of the replacement, exclusive * @param replaceWith the replacement text */ public static Replacement create(int startPosition, int endPosition, String replaceWith) { checkArgument(startPosition >= 0, "invalid startPosition: %s", startPosition); return new AutoValue_Replacement(Range.closedOpen(startPosition, endPosition), replaceWith); }
From source file:com.google.googlejavaformat.intellij.FormatterUtil.java
private static Collection<Range<Integer>> toRanges(Collection<TextRange> textRanges) { return textRanges.stream() .map(textRange -> Range.closedOpen(textRange.getStartOffset(), textRange.getEndOffset())) .collect(Collectors.toList()); }
From source file:com.pingcap.tikv.util.KeyRangeUtils.java
public static Range makeRange(ByteString startKey, ByteString endKey) { if (startKey.isEmpty() && endKey.isEmpty()) { return Range.all(); }//from ww w .j av a 2 s. c o m if (startKey.isEmpty()) { return Range.lessThan(Comparables.wrap(endKey)); } else if (endKey.isEmpty()) { return Range.atLeast(Comparables.wrap(startKey)); } return Range.closedOpen(Comparables.wrap(startKey), Comparables.wrap(endKey)); }
From source file:org.robotframework.ide.eclipse.main.plugin.assist.ProposalMatchers.java
public static ProposalMatcher embeddedKeywordsMatcher() { return new ProposalMatcher() { @Override/*from ww w .jav a 2 s . c om*/ public Optional<ProposalMatch> matches(final String userContent, final String proposalContent) { final int index = EmbeddedKeywordNamesSupport.startsWithIgnoreCase(proposalContent, userContent); if (index >= 0) { return Optional.of(new ProposalMatch(Range.closedOpen(0, index))); } else { return Optional.empty(); } } }; }
From source file:org.mskcc.shenkers.data.interval.DiscreteRangeMap.java
public Range<Double> asReal(Range<Integer> r) { Range<Integer> asClosed = RangeTools.asClosed(r); return Range.closedOpen(asClosed.lowerEndpoint().doubleValue() - 1, asClosed.upperEndpoint().doubleValue()); }
From source file:com.google.googlejavaformat.InputOutput.java
private static void addToRanges(List<Range<Integer>> ranges, int i, int k) { while (ranges.size() <= i) { ranges.add(EMPTY_RANGE);//from ww w. j ava 2 s . c o m } Range<Integer> oldValue = ranges.get(i); ranges.set(i, Range.closedOpen(oldValue.isEmpty() ? k : oldValue.lowerEndpoint(), k + 1)); }
From source file:it.units.malelab.ege.ge.operator.LengthPreservingTwoPointsCrossover.java
@Override public List<BitsGenotype> apply(List<BitsGenotype> parents, Random random) { BitsGenotype parent1 = parents.get(0); BitsGenotype parent2 = parents.get(1); int startIndex1 = Math.min(Math.max(1, random.nextInt(parent1.size())), parent1.size() - 2); int startIndex2 = Math.min(Math.max(1, random.nextInt(parent2.size())), parent2.size() - 2); int crossoverSize = Math.max(1, random.nextInt(Math.min(parent1.size() - startIndex1, parent2.size() - startIndex2))); int endIndex1 = startIndex1 + crossoverSize; int endIndex2 = startIndex2 + crossoverSize; return children(parent1, Range.closedOpen(startIndex1, endIndex1), parent2, Range.closedOpen(startIndex2, endIndex2)); }
From source file:it.units.malelab.ege.ge.genotype.initializer.QuantizedBitsInitializer.java
@Override public List<BitsGenotype> build(int n, Validator<BitsGenotype> genotypeValidator, Random random) { List<BitsGenotype> genotypes = new ArrayList<>(n); int pieces = (int) Math.ceil(Math.log(n) / Math.log(2d)); for (int i = 0; i < n; i++) { BitsGenotype genotype = new BitsGenotype(size); List<BitsGenotype> slices = genotype.slices(Utils.slices(Range.closedOpen(0, genotype.size()), pieces)); int b = 0; int v = i; for (int j = slices.size() - 1; j >= 0; j--) { if (v >= Math.pow(2, j)) { slices.get(j).flip();/*from w w w. j a v a 2s .c o m*/ v = v - (int) Math.pow(2, j); } genotype.set(b, slices.get(j)); b = b + slices.get(j).size(); } genotypes.add(genotype); } return genotypes; }
From source file:eu.interedition.text.Segment.java
public Segment(int start, int end) { this.range = Range.closedOpen(start, end); }