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

Method encloseAll

corpus/java/training/guava/collect/Range.java:327–341  ·  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

325 * @since 14.0
326 */
327 public static <C extends Comparable<?>> Range<C> encloseAll(Iterable<C> values) {
328 checkNotNull(values);
329 if (values instanceof ContiguousSet) {
330 return ((ContiguousSet<C>) values).range();
331 }
332 Iterator<C> valueIterator = values.iterator();
333 C min = checkNotNull(valueIterator.next());
334 C max = min;
335 while (valueIterator.hasNext()) {
336 C value = checkNotNull(valueIterator.next());
337 min = Ordering.natural().min(min, value);
338 max = Ordering.natural().max(max, value);
339 }
340 return closed(min, max);
341 }
342
343 final Cut<C> lowerBound;
344 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