Streams

Stream 操作的是元素,可迭代,可遍历。
可迭代放入 Collection 集合接口,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
public interface Collection<E> extends Iterable<E> {
Iterator<E> iterator();

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

default Stream<E> stream() {
return StreamSupport.stream(spliterator(), false);
}

default Stream<E> parallelStream() {
return StreamSupport.stream(spliterator(), true);
}
}


public interface Spliterator<T> {

long estimateSize();

boolean tryAdvance(Consumer<? super T> action);

default void forEachRemaining(Consumer<? super T> action) {
do { } while (tryAdvance(action));
}
}


public abstract class CountedCompleter<T> extends ForkJoinTask<T> {
public abstract void compute();

protected final boolean exec() {
compute();
return false;
}

public T getRawResult() { return null; }
}

public abstract class ForkJoinTask<V> implements Future<V>, Serializable {

protected abstract boolean exec();

}