2020你还不会Java8新特性? (22)

学完之后忘记了怎么办?记录下来。 笔记 博客。 死记硬背是没有任何用的。

ReferencePipeline /** * Abstract base class for an intermediate pipeline stage or pipeline source * stage implementing whose elements are of type {@code U}. */ //引用管道 //ReferencePipeline 表示流的源阶段与中间阶段。 //ReferencePipeline.head表示流中的源阶段。 abstract class ReferencePipeline<P_IN, P_OUT> extends AbstractPipeline<P_IN, P_OUT, Stream<P_OUT>> implements Stream<P_OUT> { } AbstractPipeline /** * Abstract base class for "pipeline" classes, which are the core * implementations of the Stream interface and its primitive specializations. * Manages construction and evaluation of stream pipelines. * * <p>An {@code AbstractPipeline} represents an initial portion of a stream * pipeline, encapsulating a stream source and zero or more intermediate * operations. The individual {@code AbstractPipeline} objects are often * referred to as <em>stages</em>, where each stage describes either the stream * source or an intermediate operation. 流管道的初始的一部分。 * * <p>A concrete intermediate stage is generally built from an * {@code AbstractPipeline}, a shape-specific pipeline class which extends it * (e.g., {@code IntPipeline}) which is also abstract, and an operation-specific * concrete class which extends that. {@code AbstractPipeline} contains most of * the mechanics of evaluating the pipeline, and implements methods that will be * used by the operation; the shape-specific classes add helper methods for * dealing with collection of results into the appropriate shape-specific * containers. *避免自动拆箱和装箱操作。 * <p>After chaining a new intermediate operation, or executing a terminal * operation, the stream is considered to be consumed, and no more intermediate * or terminal operations are permitted on this stream instance. * 当链接完一个新的中间操作或者执行了终止操作之后, 这个流被认为被消费了。不允许再被操作了。 * @implNote * <p>For sequential streams, and parallel streams without * <a href="package-summary.html#StreamOps">stateful intermediate * operations</a>, parallel streams, pipeline evaluation is done in a single * pass that "jams" all the operations together. For parallel streams with * stateful operations, execution is divided into segments, where each * stateful operations marks the end of a segment, and each segment is * evaluated separately and the result used as the input to the next * segment. In all cases, the source data is not consumed until a terminal * operation begins. 只有终止操作开始的时候,源数据才会被消费。 * @param <E_IN> type of input elements * @param <E_OUT> type of output elements * @param <S> type of the subclass implementing {@code BaseStream} * @since 1.8 */ abstract class AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>> extends PipelineHelper<E_OUT> implements BaseStream<E_OUT, S> { } 内部类,和lambda表达式之间的关系。

本质上 内部类和lambda不是一回事。只是能完成相同的操作。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpwgpf.html