jdk/src/share/classes/java/util/stream/SpinedBuffer.java
changeset 19188 bbf287c5cd92
parent 18171 2725a30c1a02
child 20507 8498104f92c3
equal deleted inserted replaced
19187:5aa85bc92303 19188:bbf287c5cd92
    26 
    26 
    27 import java.util.ArrayList;
    27 import java.util.ArrayList;
    28 import java.util.Arrays;
    28 import java.util.Arrays;
    29 import java.util.Iterator;
    29 import java.util.Iterator;
    30 import java.util.List;
    30 import java.util.List;
       
    31 import java.util.Objects;
    31 import java.util.PrimitiveIterator;
    32 import java.util.PrimitiveIterator;
    32 import java.util.Spliterator;
    33 import java.util.Spliterator;
    33 import java.util.Spliterators;
    34 import java.util.Spliterators;
    34 import java.util.function.Consumer;
    35 import java.util.function.Consumer;
    35 import java.util.function.DoubleConsumer;
    36 import java.util.function.DoubleConsumer;
   315                 return SPLITERATOR_CHARACTERISTICS;
   316                 return SPLITERATOR_CHARACTERISTICS;
   316             }
   317             }
   317 
   318 
   318             @Override
   319             @Override
   319             public boolean tryAdvance(Consumer<? super E> consumer) {
   320             public boolean tryAdvance(Consumer<? super E> consumer) {
       
   321                 Objects.requireNonNull(consumer);
       
   322 
   320                 if (splSpineIndex < lastSpineIndex
   323                 if (splSpineIndex < lastSpineIndex
   321                     || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) {
   324                     || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) {
   322                     consumer.accept(splChunk[splElementIndex++]);
   325                     consumer.accept(splChunk[splElementIndex++]);
   323 
   326 
   324                     if (splElementIndex == splChunk.length) {
   327                     if (splElementIndex == splChunk.length) {
   332                 return false;
   335                 return false;
   333             }
   336             }
   334 
   337 
   335             @Override
   338             @Override
   336             public void forEachRemaining(Consumer<? super E> consumer) {
   339             public void forEachRemaining(Consumer<? super E> consumer) {
       
   340                 Objects.requireNonNull(consumer);
       
   341 
   337                 if (splSpineIndex < lastSpineIndex
   342                 if (splSpineIndex < lastSpineIndex
   338                     || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) {
   343                     || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) {
   339                     int i = splElementIndex;
   344                     int i = splElementIndex;
   340                     // completed chunks, if any
   345                     // completed chunks, if any
   341                     for (int sp = splSpineIndex; sp < lastSpineIndex; sp++) {
   346                     for (int sp = splSpineIndex; sp < lastSpineIndex; sp++) {
   632                 return SPLITERATOR_CHARACTERISTICS;
   637                 return SPLITERATOR_CHARACTERISTICS;
   633             }
   638             }
   634 
   639 
   635             @Override
   640             @Override
   636             public boolean tryAdvance(T_CONS consumer) {
   641             public boolean tryAdvance(T_CONS consumer) {
       
   642                 Objects.requireNonNull(consumer);
       
   643 
   637                 if (splSpineIndex < lastSpineIndex
   644                 if (splSpineIndex < lastSpineIndex
   638                     || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) {
   645                     || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) {
   639                     arrayForOne(splChunk, splElementIndex++, consumer);
   646                     arrayForOne(splChunk, splElementIndex++, consumer);
   640 
   647 
   641                     if (splElementIndex == arrayLength(splChunk)) {
   648                     if (splElementIndex == arrayLength(splChunk)) {
   649                 return false;
   656                 return false;
   650             }
   657             }
   651 
   658 
   652             @Override
   659             @Override
   653             public void forEachRemaining(T_CONS consumer) {
   660             public void forEachRemaining(T_CONS consumer) {
       
   661                 Objects.requireNonNull(consumer);
       
   662 
   654                 if (splSpineIndex < lastSpineIndex
   663                 if (splSpineIndex < lastSpineIndex
   655                     || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) {
   664                     || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) {
   656                     int i = splElementIndex;
   665                     int i = splElementIndex;
   657                     // completed chunks, if any
   666                     // completed chunks, if any
   658                     for (int sp = splSpineIndex; sp < lastSpineIndex; sp++) {
   667                     for (int sp = splSpineIndex; sp < lastSpineIndex; sp++) {