spliterator()

spliterator()

Documentation

  • Creating a split iterator (defined method in Iterable Interface)
  • Class needs to implement the characteristic values ​​reported record spliterator
    • But spliterator reported size or no current collection container element, the characteristic value is no need to report
  • The default implementation needs overridden by subclasses to return to a more efficient spliterator
    • In order to retain the desired stream () and parallelStream () delay behavior, needs to have an iterative segmentation CONCURRENT IMMUTABLE or characteristic, or set to delay bound (late-binding)
    • If these requirements are not fulfilled, the need to rewrite the class of binding policy document describing the division iterator, and possible modification of behavior, and also need to rewrite stream () and parallelStream () method, spliterator to create a stream of Supplier
    • These requirements ensure that the generated content stream () or parallelStream () to terminate flow when the operation is performed can be set to reflect
    • The default implementation is to create a spliterator a late binding from the collection of Iterator, this spliterator inherit the iterator fail-fast (fast failure) property
    • Created out of spliterator contain SIZED characteristic values
    • At the same time, this also has the SUBSIZED characteristic value spliterator
    • If no element in a spliterator, the characteristic value does not help the client to report characteristic values ​​other than the SUBSIZED SIZED control, or specialized Simplified Calculation
    • This ensures that can be used to share an immutable empty empty collection spliterator of example, and can be determined to ensure that the customer does not contain any element spliterator

Source

spliterator Collection in (),

@Override
default Spliterator<E> spliterator() {
    return Spliterators.spliterator(this, 0);
}

 

Guess you like

Origin www.cnblogs.com/flying-snake/p/11520854.html