565 * but not the exact sizes of subtrees. |
565 * but not the exact sizes of subtrees. |
566 */ |
566 */ |
567 public static final int SUBSIZED = 0x00004000; |
567 public static final int SUBSIZED = 0x00004000; |
568 |
568 |
569 /** |
569 /** |
570 * A Spliterator specialized for {@code int} values. |
570 * A Spliterator specialized for primitive values. |
|
571 * |
|
572 * @param <T> the type of elements returned by this Spliterator. The |
|
573 * type must be a wrapper type for a primitive type, such as {@code Integer} |
|
574 * for the primitive {@code int} type. |
|
575 * @param <T_CONS> the type of primitive consumer. The type must be a |
|
576 * primitive specialization of {@link java.util.function.Consumer} for |
|
577 * {@code T}, such as {@link java.util.function.IntConsumer} for |
|
578 * {@code Integer}. |
|
579 * @param <T_SPLITR> the type of primitive Spliterator. The type must be |
|
580 * a primitive specialization of Spliterator for {@code T}, such as |
|
581 * {@link Spliterator.OfInt} for {@code Integer}. |
|
582 * |
|
583 * @see Spliterator.OfInt |
|
584 * @see Spliterator.OfLong |
|
585 * @see Spliterator.OfDouble |
571 * @since 1.8 |
586 * @since 1.8 |
572 */ |
587 */ |
573 public interface OfInt extends Spliterator<Integer> { |
588 public interface OfPrimitive<T, T_CONS, T_SPLITR extends Spliterator.OfPrimitive<T, T_CONS, T_SPLITR>> |
574 |
589 extends Spliterator<T> { |
575 @Override |
590 @Override |
576 OfInt trySplit(); |
591 T_SPLITR trySplit(); |
577 |
592 |
578 /** |
593 /** |
579 * If a remaining element exists, performs the given action on it, |
594 * If a remaining element exists, performs the given action on it, |
580 * returning {@code true}; else returns {@code false}. If this |
595 * returning {@code true}; else returns {@code false}. If this |
581 * Spliterator is {@link #ORDERED} the action is performed on the |
596 * Spliterator is {@link #ORDERED} the action is performed on the |
585 * @param action The action |
600 * @param action The action |
586 * @return {@code false} if no remaining elements existed |
601 * @return {@code false} if no remaining elements existed |
587 * upon entry to this method, else {@code true}. |
602 * upon entry to this method, else {@code true}. |
588 * @throws NullPointerException if the specified action is null |
603 * @throws NullPointerException if the specified action is null |
589 */ |
604 */ |
590 boolean tryAdvance(IntConsumer action); |
605 boolean tryAdvance(T_CONS action); |
591 |
606 |
592 /** |
607 /** |
593 * Performs the given action for each remaining element, sequentially in |
608 * Performs the given action for each remaining element, sequentially in |
594 * the current thread, until all elements have been processed or the |
609 * the current thread, until all elements have been processed or the |
595 * action throws an exception. If this Spliterator is {@link #ORDERED}, |
610 * action throws an exception. If this Spliterator is {@link #ORDERED}, |
602 * possible. |
617 * possible. |
603 * |
618 * |
604 * @param action The action |
619 * @param action The action |
605 * @throws NullPointerException if the specified action is null |
620 * @throws NullPointerException if the specified action is null |
606 */ |
621 */ |
|
622 default void forEachRemaining(T_CONS action) { |
|
623 do { } while (tryAdvance(action)); |
|
624 } |
|
625 } |
|
626 |
|
627 /** |
|
628 * A Spliterator specialized for {@code int} values. |
|
629 * @since 1.8 |
|
630 */ |
|
631 public interface OfInt extends OfPrimitive<Integer, IntConsumer, OfInt> { |
|
632 |
|
633 @Override |
|
634 OfInt trySplit(); |
|
635 |
|
636 @Override |
|
637 boolean tryAdvance(IntConsumer action); |
|
638 |
|
639 @Override |
607 default void forEachRemaining(IntConsumer action) { |
640 default void forEachRemaining(IntConsumer action) { |
608 do { } while (tryAdvance(action)); |
641 do { } while (tryAdvance(action)); |
609 } |
642 } |
610 |
643 |
611 /** |
644 /** |
657 |
690 |
658 /** |
691 /** |
659 * A Spliterator specialized for {@code long} values. |
692 * A Spliterator specialized for {@code long} values. |
660 * @since 1.8 |
693 * @since 1.8 |
661 */ |
694 */ |
662 public interface OfLong extends Spliterator<Long> { |
695 public interface OfLong extends OfPrimitive<Long, LongConsumer, OfLong> { |
663 |
696 |
664 @Override |
697 @Override |
665 OfLong trySplit(); |
698 OfLong trySplit(); |
666 |
699 |
667 /** |
700 @Override |
668 * If a remaining element exists, performs the given action on it, |
|
669 * returning {@code true}; else returns {@code false}. If this |
|
670 * Spliterator is {@link #ORDERED} the action is performed on the |
|
671 * next element in encounter order. Exceptions thrown by the |
|
672 * action are relayed to the caller. |
|
673 * |
|
674 * @param action The action |
|
675 * @return {@code false} if no remaining elements existed |
|
676 * upon entry to this method, else {@code true}. |
|
677 * @throws NullPointerException if the specified action is null |
|
678 */ |
|
679 boolean tryAdvance(LongConsumer action); |
701 boolean tryAdvance(LongConsumer action); |
680 |
702 |
681 /** |
703 @Override |
682 * Performs the given action for each remaining element, sequentially in |
|
683 * the current thread, until all elements have been processed or the |
|
684 * action throws an exception. If this Spliterator is {@link #ORDERED}, |
|
685 * actions are performed in encounter order. Exceptions thrown by the |
|
686 * action are relayed to the caller. |
|
687 * |
|
688 * @implSpec |
|
689 * The default implementation repeatedly invokes {@link #tryAdvance} |
|
690 * until it returns {@code false}. It should be overridden whenever |
|
691 * possible. |
|
692 * |
|
693 * @param action The action |
|
694 * @throws NullPointerException if the specified action is null |
|
695 */ |
|
696 default void forEachRemaining(LongConsumer action) { |
704 default void forEachRemaining(LongConsumer action) { |
697 do { } while (tryAdvance(action)); |
705 do { } while (tryAdvance(action)); |
698 } |
706 } |
699 |
707 |
700 /** |
708 /** |
746 |
754 |
747 /** |
755 /** |
748 * A Spliterator specialized for {@code double} values. |
756 * A Spliterator specialized for {@code double} values. |
749 * @since 1.8 |
757 * @since 1.8 |
750 */ |
758 */ |
751 public interface OfDouble extends Spliterator<Double> { |
759 public interface OfDouble extends OfPrimitive<Double, DoubleConsumer, OfDouble> { |
752 |
760 |
753 @Override |
761 @Override |
754 OfDouble trySplit(); |
762 OfDouble trySplit(); |
755 |
763 |
756 /** |
764 @Override |
757 * If a remaining element exists, performs the given action on it, |
|
758 * returning {@code true}; else returns {@code false}. If this |
|
759 * Spliterator is {@link #ORDERED} the action is performed on the |
|
760 * next element in encounter order. Exceptions thrown by the |
|
761 * action are relayed to the caller. |
|
762 * |
|
763 * @param action The action |
|
764 * @return {@code false} if no remaining elements existed |
|
765 * upon entry to this method, else {@code true}. |
|
766 * @throws NullPointerException if the specified action is null |
|
767 */ |
|
768 boolean tryAdvance(DoubleConsumer action); |
765 boolean tryAdvance(DoubleConsumer action); |
769 |
766 |
770 /** |
767 @Override |
771 * Performs the given action for each remaining element, sequentially in |
|
772 * the current thread, until all elements have been processed or the |
|
773 * action throws an exception. If this Spliterator is {@link #ORDERED}, |
|
774 * actions are performed in encounter order. Exceptions thrown by the |
|
775 * action are relayed to the caller. |
|
776 * |
|
777 * @implSpec |
|
778 * The default implementation repeatedly invokes {@link #tryAdvance} |
|
779 * until it returns {@code false}. It should be overridden whenever |
|
780 * possible. |
|
781 * |
|
782 * @param action The action |
|
783 * @throws NullPointerException if the specified action is null |
|
784 */ |
|
785 default void forEachRemaining(DoubleConsumer action) { |
768 default void forEachRemaining(DoubleConsumer action) { |
786 do { } while (tryAdvance(action)); |
769 do { } while (tryAdvance(action)); |
787 } |
770 } |
788 |
771 |
789 /** |
772 /** |