789 *
790 * @param startInclusive the (inclusive) initial value
791 * @param endInclusive the inclusive upper bound
792 * @return a sequential {@code IntStream} for the range of {@code int}
793 * elements
794 */
795 public static IntStream rangeClosed(int startInclusive, int endInclusive) {
796 if (startInclusive > endInclusive) {
797 return empty();
798 } else {
799 return StreamSupport.intStream(
800 new Streams.RangeIntSpliterator(startInclusive, endInclusive, true), false);
801 }
802 }
803
804 /**
805 * Creates a lazy concatenated {@code IntStream} whose elements are all the
806 * elements of a first {@code IntStream} succeeded by all the elements of the
807 * second {@code IntStream}. The resulting stream is ordered if both
808 * of the input streams are ordered, and parallel if either of the input
809 * streams is parallel.
810 *
811 * @param a the first stream
812 * @param b the second stream to concatenate on to end of the first stream
813 * @return the concatenation of the two streams
814 */
815 public static IntStream concat(IntStream a, IntStream b) {
816 Objects.requireNonNull(a);
817 Objects.requireNonNull(b);
818
819 Spliterator.OfInt split = new Streams.ConcatSpliterator.OfInt(
820 a.spliterator(), b.spliterator());
821 return StreamSupport.intStream(split, a.isParallel() || b.isParallel());
822 }
823
824 /**
825 * A mutable builder for an {@code IntStream}.
826 *
827 * <p>A stream builder has a lifecycle, where it starts in a building
828 * phase, during which elements can be added, and then transitions to a
829 * built phase, after which elements may not be added. The built phase
830 * begins when the {@link #build()} method is called, which creates an
831 * ordered stream whose elements are the elements that were added to the
832 * stream builder, in the order they were added.
833 *
834 * @see IntStream#builder()
835 * @since 1.8
836 */
837 public interface Builder extends IntConsumer {
838
839 /**
840 * Adds an element to the stream being built.
841 *
|
789 *
790 * @param startInclusive the (inclusive) initial value
791 * @param endInclusive the inclusive upper bound
792 * @return a sequential {@code IntStream} for the range of {@code int}
793 * elements
794 */
795 public static IntStream rangeClosed(int startInclusive, int endInclusive) {
796 if (startInclusive > endInclusive) {
797 return empty();
798 } else {
799 return StreamSupport.intStream(
800 new Streams.RangeIntSpliterator(startInclusive, endInclusive, true), false);
801 }
802 }
803
804 /**
805 * Creates a lazy concatenated {@code IntStream} whose elements are all the
806 * elements of a first {@code IntStream} succeeded by all the elements of the
807 * second {@code IntStream}. The resulting stream is ordered if both
808 * of the input streams are ordered, and parallel if either of the input
809 * streams is parallel. When the resulting stream is closed, the close
810 * handlers for both input streams is invoked.
811 *
812 * @param a the first stream
813 * @param b the second stream to concatenate on to end of the first stream
814 * @return the concatenation of the two streams
815 */
816 public static IntStream concat(IntStream a, IntStream b) {
817 Objects.requireNonNull(a);
818 Objects.requireNonNull(b);
819
820 Spliterator.OfInt split = new Streams.ConcatSpliterator.OfInt(
821 a.spliterator(), b.spliterator());
822 IntStream stream = StreamSupport.intStream(split, a.isParallel() || b.isParallel());
823 return stream.onClose(Streams.composedClose(a, b));
824 }
825
826 /**
827 * A mutable builder for an {@code IntStream}.
828 *
829 * <p>A stream builder has a lifecycle, where it starts in a building
830 * phase, during which elements can be added, and then transitions to a
831 * built phase, after which elements may not be added. The built phase
832 * begins when the {@link #build()} method is called, which creates an
833 * ordered stream whose elements are the elements that were added to the
834 * stream builder, in the order they were added.
835 *
836 * @see IntStream#builder()
837 * @since 1.8
838 */
839 public interface Builder extends IntConsumer {
840
841 /**
842 * Adds an element to the stream being built.
843 *
|