録画した後、他の人に繰り返し、あなたが習得しました。
忘れ完了した後にどのように行うには?録画。ノートはブログ。ローテは役に立ちません。
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> {
}
内部クラス、およびラムダ式との関係。
基本的に内部クラスとラムダないと同じこと。ただ、同じ操作を完了します。
糖衣構文ラムダは匿名内部クラス、またはその略語ではありません。それは新しい形です。
public class LambdaTest {
//内部类,和lambda表达式之间的关系。
Runnable r1 = () -> System.out.println(this); // this表示当前类的对象
//匿名内部类
Runnable r2 = new Runnable() { //
@Override
public void run() {
System.out.println(this);
// this 表示匿名内部类的对象
}
};
public static void main(String[] args) {
LambdaTest lambdaTest = new LambdaTest();
Thread t1 = new Thread(lambdaTest.r1);
t1.start();
System.out.println("- - -- - ");
Thread t2 = new Thread(lambdaTest.r2);
t2.start();
//输出结果。
//com.sinosoft.lis.test.LambdaTest@62661526
//com.sinosoft.lis.test.LambdaTest$1@59a30351
}
}
使用するテンプレートメソッドパターンを。
ストリームは不活性であり、動作が遅延されます。操作を終了すると、操作を実行します。
TerminalOp。クラスのインターフェイスの動作を終了します。
操作の終了はわずか4種類、findOp foreachOp matchOp reduceOpです
PipelineHelper
オペレーティングシステムレベルの分析と設計分析の中間動作および終了をストリーミング
中級操作
BaseStream - 「AbStractpipeline - "ReferencePipeline - 「ヘッド|| StatelessOP || statefulOp
中間パイプ部材可変電流源構成最上位ソース多くのソースステートレス動作ステートフル中間操作
ストリームは不活性であり、動作が遅延されます。操作を終了すると、操作を実行します。積分動作(シンク)の途中でノー終了操作まで。
操作の終了
TerminalOp - "FindOp || ForeachOp || MatchOp || reduceOp
一番上の
TerminalSink
飲酒の終了。