@Override public int getValueCapacity() { if (size() == 0) { return 0; } final Ordering<ValueVector> natural = new Ordering<ValueVector>() { @Override public int compare(@Nullable ValueVector left, @Nullable ValueVector right) { return Ints.compare( Preconditions.checkNotNull(left).getValueCapacity(), Preconditions.checkNotNull(right).getValueCapacity() ); } }; return natural.min(getChildren()).getValueCapacity(); }
@Override public <E extends T> E max(E a, E b) { return forwardOrder.min(a, b); }
@Override public <E extends T> E max(E a, E b, E c, E... rest) { return forwardOrder.min(a, b, c, rest); }
@Override public <E extends T> E max(Iterator<E> iterator) { return forwardOrder.min(iterator); }
@Override public <E extends T> E max(Iterable<E> iterable) { return forwardOrder.min(iterable); }
/** * Returns the least of the specified values according to this ordering. If there are multiple * least values, the first of those is returned. * * <p><b>Java 8 users:</b> Use {@code Collections.min(Arrays.asList(a, b, c...), thisComparator)} * instead (but note that it does not guarantee which tied minimum element is returned). * * @param a value to compare, returned if less than or equal to the rest. * @param b value to compare * @param c value to compare * @param rest values to compare * @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this * ordering. */ @CanIgnoreReturnValue // TODO(kak): Consider removing this public <E extends T> E min(@Nullable E a, @Nullable E b, @Nullable E c, E... rest) { E minSoFar = min(min(a, b), c); for (E r : rest) { minSoFar = min(minSoFar, r); } return minSoFar; }
/** * Returns the least of the specified values according to this ordering. If there are multiple * least values, the first of those is returned. * * <p><b>Java 8 users:</b> If {@code iterable} is a {@link Collection}, use {@code * Collections.min(collection, thisComparator)} instead. Otherwise, continue to use this method * for now. After the next release of Guava, use {@code * Streams.stream(iterable).min(thisComparator).get()} instead. Note that these alternatives do * not guarantee which tied minimum element is returned) * * @param iterable the iterable whose minimum element is to be determined * @throws NoSuchElementException if {@code iterable} is empty * @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this * ordering. */ @CanIgnoreReturnValue // TODO(kak): Consider removing this public <E extends T> E min(Iterable<E> iterable) { return min(iterable.iterator()); }
/** * Returns the least of the specified values according to this ordering. If there are multiple * least values, the first of those is returned. The iterator will be left exhausted: its {@code * hasNext()} method will return {@code false}. * * <p><b>Java 8 users:</b> Continue to use this method for now. After the next release of Guava, * use {@code Streams.stream(iterator).min(thisComparator).get()} instead (but note that it does * not guarantee which tied minimum element is returned). * * @param iterator the iterator whose minimum element is to be determined * @throws NoSuchElementException if {@code iterator} is empty * @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this * ordering. * @since 11.0 */ @CanIgnoreReturnValue // TODO(kak): Consider removing this public <E extends T> E min(Iterator<E> iterator) { // let this throw NoSuchElementException as necessary E minSoFar = iterator.next(); while (iterator.hasNext()) { minSoFar = min(minSoFar, iterator.next()); } return minSoFar; }
@Override public int getValueCapacity() { if (size() == 0) { return 0; } final Ordering<ValueVector> natural = new Ordering<ValueVector>() { @Override public int compare(@Nullable ValueVector left, @Nullable ValueVector right) { return Ints.compare( Preconditions.checkNotNull(left).getValueCapacity(), Preconditions.checkNotNull(right).getValueCapacity() ); } }; return natural.min(getChildren()).getValueCapacity(); }
/** * Returns the minimal range that * {@linkplain Range#contains(Comparable) contains} all of the given values. * The returned range is {@linkplain BoundType#CLOSED closed} on both ends. * * @throws ClassCastException if the parameters are not <i>mutually * comparable</i> * @throws NoSuchElementException if {@code values} is empty * @throws NullPointerException if any of {@code values} is null * @since 14.0 */ public static <C extends Comparable<?>> Range<C> encloseAll(Iterable<C> values) { checkNotNull(values); if (values instanceof SortedSet) { SortedSet<? extends C> set = cast(values); Comparator<?> comparator = set.comparator(); if (Ordering.natural().equals(comparator) || comparator == null) { return closed(set.first(), set.last()); } } Iterator<C> valueIterator = values.iterator(); C min = checkNotNull(valueIterator.next()); C max = min; while (valueIterator.hasNext()) { C value = checkNotNull(valueIterator.next()); min = Ordering.natural().min(min, value); max = Ordering.natural().max(max, value); } return closed(min, max); }
.min(lowerBoundWindow.upperBound, Cut.belowValue(restriction.upperBound)); final Iterator<Range<C>> completeRangeItr = rangesByLowerBound
.min(lowerBoundWindow.upperBound, Cut.belowValue(restriction.upperBound)); return new AbstractIterator<Entry<Cut<C>, Range<C>>>() { @Override
@Override public ContiguousSet<C> intersection(ContiguousSet<C> other) { checkNotNull(other); checkArgument(this.domain.equals(other.domain)); if (other.isEmpty()) { return other; } else { C lowerEndpoint = Ordering.natural().max(this.first(), other.first()); C upperEndpoint = Ordering.natural().min(this.last(), other.last()); return (lowerEndpoint.compareTo(upperEndpoint) <= 0) ? ContiguousSet.create(Range.closed(lowerEndpoint, upperEndpoint), domain) : new EmptyContiguousSet<C>(domain); } }