/** * Returns a {@link Set} containing the elements of this stream. The * returned {@code Set} is guaranteed to be mutable, but there are no * guarantees on the type, serializability, or thread-safety; if more * control over the returned {@code Set} is required, use * {@link #toCollection(Supplier)}. * * <p> * This is a terminal operation. * * @return a {@code Set} containing the elements of this stream * @see Collectors#toSet() */ public Set<T> toSet() { return rawCollect(Collectors.toSet()); }
/** * Returns a {@link Collection} containing the elements of this stream. The * {@code Collection} is created by the provided factory. * * <p> * This is a terminal operation. * * @param <C> the type of the resulting {@code Collection} * @param collectionFactory a {@code Supplier} which returns a new, empty * {@code Collection} of the appropriate type * @return a {@code Collection} containing the elements of this stream * @see Collectors#toCollection(Supplier) */ public <C extends Collection<T>> C toCollection(Supplier<C> collectionFactory) { return rawCollect(Collectors.toCollection(collectionFactory)); }
new StreamEx<>(StreamSupport.stream(spltr, true), context).findFirst().get()); return rawCollect(collector);