Updating the coverage ranges.

@param range the global range array.
@param grammar The grammar (i.e. set of rules) used for this update.

@return an updated array.
489975
public static boolean[] updateRanges(boolean[] range, GrammarRules grammar) {
    boolean[] res = Arrays.copyOf(range, range.length);
    for (GrammarRuleRecord r : grammar) {
      if (0 == r.getRuleNumber()) {
        continue;
      }
      res = updateRanges(res, r.getRuleIntervals());
    }
    return res;
  }
394236
public static Set<Integer> parseRange(String range) {
        if (range == null) {
            return Collections.emptySet();
        }
        Set<Integer> ret = new LinkedHashSet<>();
        StringTokenizer stringTokenizer = new StringTokenizer(range, String.format("%s%s", COMMA, DASH), true);
        Integer from = null;
        Integer to = null;
        boolean rangeStarted = false;
        while (stringTokenizer.hasMoreTokens()) {
            String token = stringTokenizer.nextToken();
            if (isValueDelimiter(token)) {
                ret.addAll(fromToAsSet(from, to));
                from = null;
                to = null;
                rangeStarted = false;
            } else if (isRangeDelimiter(token)) {
                rangeStarted = true;
            } else {
                String trimmedValue = token.trim();
                if (!isPositiveInt(trimmedValue)) {
                    throw new IllegalArgumentException("Range values should be positive numbers.");
                }
                Integer parsedInteger = Integer.parseUnsignedInt(trimmedValue);
                if (rangeStarted) {
                    to = parsedInteger;
                } else {
                    from = parsedInteger;
                }
            }
            if (from != null) {
                ret.addAll(fromToAsSet(from, to));
            }
        }

        return ret;
    }
44975
public static Keyword findFirstKeywordWithSameConflicts(final Keyword element, final Grammar grammar) {
		final List<AbstractRule> conflicting = getConflictingLexerRules(element, grammar);
		Keyword result = element;
		Iterator<Keyword> iterator = Iterators.filter(
				Iterators.filter(EcoreUtil.getAllContents(grammar, true), Keyword.class), new Predicate<Keyword>() {
					@Override
					public boolean apply(Keyword param) {
						if (GrammarUtil.containingParserRule(param) == null)
							return false;
						final List<AbstractRule> otherConflicting = getConflictingLexerRules(param, grammar);
						return otherConflicting != null && otherConflicting.equals(conflicting);
					}
				});
		if (iterator.hasNext())
			result = iterator.next();

		return result;
	}
57707
public static boolean isValid(Range range) {
        if (range == null) {
            return false;
        }
        
        double min = range.getMinimum().doubleValue();
        double max = range.getMaximum().doubleValue();
        
        return min != max && !Double.isNaN(min) && !Double.isInfinite(min) &&
                !Double.isNaN(max) && !Double.isInfinite(max);
    }
877760
@SuppressWarnings("unchecked")
    public static List<Integer> getAt(int[] array, ObjectRange range) {
        return primitiveArrayGet(array, range);
    }
1252479
@SuppressWarnings("unchecked")
    public static List<Double> getAt(double[] array, ObjectRange range) {
        return primitiveArrayGet(array, range);
    }
612497
public static String getAt(GString text, Range range) {
        return getAt(text.toString(), range);
    }
56252
function(sel, range) {
            var ranges = sel.getAllRanges();
            sel.removeAllRanges();
            for (var i = 0, len = ranges.length; i < len; ++i) {
                if (!rangesEqual(range, ranges[i])) {
                    sel.addRange(ranges[i]);
                }
            }
            if (!sel.rangeCount) {
                updateEmptySelection(sel);
            }
        }
201406
public Range intersection(final Range range) {
		int c0 = Math.max(this.start, range.start);
		int c1 = Math.min(this.end, range.end);
		return c0 <= c1 ? new Range(c0, c1) : null;
	}
1089186
public VersionRange range(final int... parts) {
    checkNotNull(parts);
    checkArgument(parts.length != 0);

    StringBuilder buff = new StringBuilder()
        .append("[");

    for (int i = 0; i < parts.length; i++) {
      buff.append(parts[i]);
      if (i + 1 < parts.length) {
        buff.append(".");
      }
    }

    buff.append(",");

    for (int i = 0; i < parts.length; i++) {
      if (i + 1 == parts.length) {
        buff.append(parts[i] + 1);
      }
      else {
        buff.append(parts[i])
            .append(".");
      }
    }

    buff.append(")");

    log.trace("Range pattern: {}", buff);

    return parseRange(buff.toString());
  }
931752
public static void parse(final String range, final RangeConfig tc) throws RangeException {
        if (range == null) {
            throw new RangeException("Range can't be null");
        }
        ROOT_STAGE.parse(range, tc);
        checkBoundaries(tc);
    }
605272
public ValidatorBuilderInteger<PARENT> range(int min, int max) {

    return range(new Range<>(Integer.valueOf(min), Integer.valueOf(max)));
  }
442171
public double getCoverDelta(GrammarRuleRecord rule) {

    // counts which uncovered points shall be covered
    int new_cover = 0;

    // counts overlaps with previously covered ranges
    int overlapping_cover = 0;

    // perform the sum computation
    for (RuleInterval i : rule.getRuleIntervals()) {
      int start = i.getStart();
      int end = i.getEnd();
      for (int j = start; j < end; j++) {
        if (range[j]) {
          overlapping_cover++;
        }
        else {
          new_cover++;
        }
      }
    }

    // if covers nothing, return 0
    if (0 == new_cover) {
      return 0.0;
    }

    // if zero overlap, return full weighted cover
    if (0 == overlapping_cover) {
      return (double) new_cover
              / (double) (rule.getExpandedRuleString().length() + rule.getRuleIntervals().size());
    }

    // else divide newly covered points amount by the sum of the rule string length and occurrence
    // (i.e. encoding size)
    return ((double) new_cover / (double) (new_cover + overlapping_cover))
            / (double) (rule.getExpandedRuleString().length() + rule.getRuleIntervals().size());
  }
1276593
public static int updateInteger(int value, int range) {
		range = range == 0 ? (int) (0.1 * value) : range;
		int min = value - range;
		int max = value + range;
		return nextInteger(min, max);
	}
1245184
@SuppressWarnings("unchecked")
    public static List<Boolean> getAt(boolean[] array, ObjectRange range) {
        return primitiveArrayGet(array, range);
    }
438477
public static CharRanges withRanges(int... ranges) {
    if ((ranges.length & 1) != 0) { throw new IllegalArgumentException(); }
    for (int i = 1; i < ranges.length; ++i) {
      if (ranges[i] <= ranges[i - 1]) {
        throw new IllegalArgumentException(ranges[i] + " > " + ranges[i - 1]);
      }
    }
    return new CharRanges(ranges);
  }
795287
public static Protos.Resource ranges(String name, String role, Protos.Value.Range... ranges) {
		checkNotNull(name);
		checkNotNull(role);
		checkNotNull(ranges);
		return Protos.Resource.newBuilder()
			.setName(name)
			.setType(Protos.Value.Type.RANGES)
			.setRanges(Protos.Value.Ranges.newBuilder().addAllRange(Arrays.asList(ranges)).build())
			.setRole(role)
			.build();
	}