/** * Performs a cross product of current stream with specified * {@link Collection} of elements. As a result the {@link EntryStream} is * created whose keys are elements of current stream and values are elements * of the specified collection. * * <p> * The resulting stream contains all the possible combinations of keys and * values. * * <p> * This is an <a href="package-summary.html#StreamOps">intermediate</a> * operation. * * @param <V> the type of collection elements * @param other the collection to perform a cross product with * @return the new {@code EntryStream} * @throws NullPointerException if other is null * @since 0.2.3 */ public <V> EntryStream<T, V> cross(Collection<? extends V> other) { if (other.isEmpty()) return new EntryStream<>(Spliterators.emptySpliterator(), context); return cross(t -> of(other)); }
if (other.length == 1) return mapToEntry(e -> other[0]); return cross(t -> of(other));