634 * The following will accumulate strings into an ArrayList:
635 * <pre>{@code
636 * List<String> asList = stringStream.collect(Collectors.toList());
637 * }</pre>
638 *
639 * <p>The following will classify {@code Person} objects by city:
640 * <pre>{@code
641 * Map<String, Collection<Person>> peopleByCity
642 * = personStream.collect(Collectors.groupBy(Person::getCity));
643 * }</pre>
644 *
645 * <p>The following will classify {@code Person} objects by state and city,
646 * cascading two {@code Collector}s together:
647 * <pre>{@code
648 * Map<String, Map<String, Collection<Person>>> peopleByStateAndCity
649 * = personStream.collect(Collectors.groupBy(Person::getState,
650 * Collectors.groupBy(Person::getCity)));
651 * }</pre>
652 *
653 * @param <R> the type of the result
654 * @param collector the {@code Collector} describing the reduction
655 * @return the result of the reduction
656 * @see #collect(Supplier, BiConsumer, BiConsumer)
657 * @see Collectors
658 */
659 <R> R collect(Collector<? super T, R> collector);
660
661 /**
662 * Returns the minimum element of this stream according to the provided
663 * {@code Comparator}. This is a special case of a
664 * <a href="package-summary.html#MutableReduction">reduction</a>.
665 *
666 * <p>This is a <a href="package-summary.html#StreamOps">terminal operation</a>.
667 *
668 * @param comparator a <a href="package-summary.html#NonInterference">non-interfering,
669 * stateless</a> {@code Comparator} to use to compare
670 * elements of this stream
671 * @return an {@code Optional} describing the minimum element of this stream,
672 * or an empty {@code Optional} if the stream is empty
673 */
674 Optional<T> min(Comparator<? super T> comparator);
675
676 /**
677 * Returns the maximum element of this stream according to the provided
678 * {@code Comparator}. This is a special case of a
679 * <a href="package-summary.html#MutableReduction">reduction</a>.
|
634 * The following will accumulate strings into an ArrayList:
635 * <pre>{@code
636 * List<String> asList = stringStream.collect(Collectors.toList());
637 * }</pre>
638 *
639 * <p>The following will classify {@code Person} objects by city:
640 * <pre>{@code
641 * Map<String, Collection<Person>> peopleByCity
642 * = personStream.collect(Collectors.groupBy(Person::getCity));
643 * }</pre>
644 *
645 * <p>The following will classify {@code Person} objects by state and city,
646 * cascading two {@code Collector}s together:
647 * <pre>{@code
648 * Map<String, Map<String, Collection<Person>>> peopleByStateAndCity
649 * = personStream.collect(Collectors.groupBy(Person::getState,
650 * Collectors.groupBy(Person::getCity)));
651 * }</pre>
652 *
653 * @param <R> the type of the result
654 * @param <A> the intermediate accumulation type of the {@code Collector}
655 * @param collector the {@code Collector} describing the reduction
656 * @return the result of the reduction
657 * @see #collect(Supplier, BiConsumer, BiConsumer)
658 * @see Collectors
659 */
660 <R, A> R collect(Collector<? super T, A, R> collector);
661
662 /**
663 * Returns the minimum element of this stream according to the provided
664 * {@code Comparator}. This is a special case of a
665 * <a href="package-summary.html#MutableReduction">reduction</a>.
666 *
667 * <p>This is a <a href="package-summary.html#StreamOps">terminal operation</a>.
668 *
669 * @param comparator a <a href="package-summary.html#NonInterference">non-interfering,
670 * stateless</a> {@code Comparator} to use to compare
671 * elements of this stream
672 * @return an {@code Optional} describing the minimum element of this stream,
673 * or an empty {@code Optional} if the stream is empty
674 */
675 Optional<T> min(Comparator<? super T> comparator);
676
677 /**
678 * Returns the maximum element of this stream according to the provided
679 * {@code Comparator}. This is a special case of a
680 * <a href="package-summary.html#MutableReduction">reduction</a>.
|