MCPcopy Create free account
hub / github.com/antlr/codebuff / encloseAll

Method encloseAll

output/java_guava/1.4.17/Range.java:346–360  ·  view source on GitHub ↗

Returns the minimal range that plain Range#contains(Comparable) contains all of the given values. The returned range is plain BoundType#CLOSED closed on both ends. @throws ClassCastException if the parameters are not mutually comparable @throws NoSuchElementException if {@c

(Iterable<C> values)

Source from the content-addressed store, hash-verified

344
345
346 public static <C extends Comparable<?>> Range<C> encloseAll(Iterable<C> values) {
347 checkNotNull(values);
348 if (values instanceof ContiguousSet) {
349 return ((ContiguousSet<C>) values).range();
350 }
351 Iterator<C> valueIterator = values.iterator();
352 C min = checkNotNull(valueIterator.next());
353 C max = min;
354 while (valueIterator.hasNext()) {
355 C value = checkNotNull(valueIterator.next());
356 min = Ordering.natural().min(min, value);
357 max = Ordering.natural().max(max, value);
358 }
359 return closed(min, max);
360 }
361
362 final Cut<C> lowerBound;
363 final Cut<C> upperBound;

Callers

nothing calls this directly

Calls 9

naturalMethod · 0.95
closedMethod · 0.95
rangeMethod · 0.65
iteratorMethod · 0.65
nextMethod · 0.65
checkNotNullMethod · 0.45
hasNextMethod · 0.45
minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected