Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
6fd41038
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6fd41038
编写于
7月 03, 2013
作者:
P
psandoz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8019395: Consolidate StreamSupport.{stream,parallelStream} into a single method
Reviewed-by: henryjen, briangoetz
上级
1d53b6a9
变更
28
展开全部
隐藏空白更改
内联
并排
Showing
28 changed file
with
212 addition
and
410 deletion
+212
-410
src/share/classes/java/io/BufferedReader.java
src/share/classes/java/io/BufferedReader.java
+1
-1
src/share/classes/java/lang/CharSequence.java
src/share/classes/java/lang/CharSequence.java
+4
-2
src/share/classes/java/nio/X-Buffer.java.template
src/share/classes/java/nio/X-Buffer.java.template
+1
-1
src/share/classes/java/nio/file/Files.java
src/share/classes/java/nio/file/Files.java
+17
-10
src/share/classes/java/util/Arrays.java
src/share/classes/java/util/Arrays.java
+4
-4
src/share/classes/java/util/BitSet.java
src/share/classes/java/util/BitSet.java
+2
-1
src/share/classes/java/util/Collection.java
src/share/classes/java/util/Collection.java
+2
-2
src/share/classes/java/util/Collections.java
src/share/classes/java/util/Collections.java
+2
-2
src/share/classes/java/util/jar/JarFile.java
src/share/classes/java/util/jar/JarFile.java
+1
-1
src/share/classes/java/util/regex/Pattern.java
src/share/classes/java/util/regex/Pattern.java
+1
-1
src/share/classes/java/util/stream/DoubleStream.java
src/share/classes/java/util/stream/DoubleStream.java
+5
-7
src/share/classes/java/util/stream/IntStream.java
src/share/classes/java/util/stream/IntStream.java
+7
-9
src/share/classes/java/util/stream/LongStream.java
src/share/classes/java/util/stream/LongStream.java
+7
-9
src/share/classes/java/util/stream/Stream.java
src/share/classes/java/util/stream/Stream.java
+5
-7
src/share/classes/java/util/stream/StreamSupport.java
src/share/classes/java/util/stream/StreamSupport.java
+95
-293
src/share/classes/java/util/stream/Streams.java
src/share/classes/java/util/stream/Streams.java
+4
-7
src/share/classes/java/util/zip/ZipFile.java
src/share/classes/java/util/zip/ZipFile.java
+1
-1
test/java/util/stream/bootlib/java/util/stream/DoubleStreamTestScenario.java
...am/bootlib/java/util/stream/DoubleStreamTestScenario.java
+3
-3
test/java/util/stream/bootlib/java/util/stream/IntStreamTestScenario.java
...tream/bootlib/java/util/stream/IntStreamTestScenario.java
+4
-3
test/java/util/stream/bootlib/java/util/stream/LongStreamTestScenario.java
...ream/bootlib/java/util/stream/LongStreamTestScenario.java
+3
-3
test/java/util/stream/bootlib/java/util/stream/StreamTestScenario.java
...l/stream/bootlib/java/util/stream/StreamTestScenario.java
+3
-3
test/java/util/stream/bootlib/java/util/stream/TestData.java
test/java/util/stream/bootlib/java/util/stream/TestData.java
+16
-16
test/java/util/stream/test/org/openjdk/tests/java/util/stream/DistinctOpTest.java
...st/org/openjdk/tests/java/util/stream/DistinctOpTest.java
+2
-2
test/java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest.java
...tests/java/util/stream/InfiniteStreamWithLimitOpTest.java
+1
-1
test/java/util/stream/test/org/openjdk/tests/java/util/stream/MatchOpTest.java
.../test/org/openjdk/tests/java/util/stream/MatchOpTest.java
+4
-4
test/java/util/stream/test/org/openjdk/tests/java/util/stream/SliceOpTest.java
.../test/org/openjdk/tests/java/util/stream/SliceOpTest.java
+1
-1
test/java/util/stream/test/org/openjdk/tests/java/util/stream/SortedOpTest.java
...test/org/openjdk/tests/java/util/stream/SortedOpTest.java
+4
-4
test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java
...openjdk/tests/java/util/stream/StreamSpliteratorTest.java
+12
-12
未找到文件。
src/share/classes/java/io/BufferedReader.java
浏览文件 @
6fd41038
...
...
@@ -587,6 +587,6 @@ public class BufferedReader extends Reader {
}
}
};
return
StreamSupport
.
stream
(
Spliterators
.
spliteratorUnknownSize
(
iter
,
Spliterator
.
ORDERED
));
return
StreamSupport
.
stream
(
Spliterators
.
spliteratorUnknownSize
(
iter
,
Spliterator
.
ORDERED
)
,
false
);
}
}
src/share/classes/java/lang/CharSequence.java
浏览文件 @
6fd41038
...
...
@@ -156,7 +156,8 @@ public interface CharSequence {
new
CharIterator
(),
length
(),
Spliterator
.
ORDERED
),
Spliterator
.
SUBSIZED
|
Spliterator
.
SIZED
|
Spliterator
.
ORDERED
);
Spliterator
.
SUBSIZED
|
Spliterator
.
SIZED
|
Spliterator
.
ORDERED
,
false
);
}
/**
...
...
@@ -227,6 +228,7 @@ public interface CharSequence {
Spliterators
.
spliteratorUnknownSize
(
new
CodePointIterator
(),
Spliterator
.
ORDERED
),
Spliterator
.
SUBSIZED
|
Spliterator
.
SIZED
|
Spliterator
.
ORDERED
);
Spliterator
.
SUBSIZED
|
Spliterator
.
SIZED
|
Spliterator
.
ORDERED
,
false
);
}
}
src/share/classes/java/nio/X-Buffer.java.template
浏览文件 @
6fd41038
...
...
@@ -1495,7 +1495,7 @@ public abstract class $Type$Buffer
#end[char]
public $Streamtype$Stream $type$s() {
return StreamSupport.$streamtype$Stream(() -> new $Type$BufferSpliterator(this),
Buffer.SPLITERATOR_CHARACTERISTICS);
Buffer.SPLITERATOR_CHARACTERISTICS
, false
);
}
#end[streamableType]
...
...
src/share/classes/java/nio/file/Files.java
浏览文件 @
6fd41038
...
...
@@ -3269,9 +3269,10 @@ public final class Files {
}
};
return
new
DelegatingCloseableStream
<>(
ds
,
StreamSupport
.
stream
(
Spliterators
.
spliteratorUnknownSize
(
it
,
Spliterator
.
DISTINCT
)));
Stream
<
Path
>
s
=
StreamSupport
.
stream
(
Spliterators
.
spliteratorUnknownSize
(
it
,
Spliterator
.
DISTINCT
),
false
);
return
new
DelegatingCloseableStream
<>(
ds
,
s
);
}
/**
...
...
@@ -3358,9 +3359,12 @@ public final class Files {
throws
IOException
{
FileTreeIterator
iterator
=
new
FileTreeIterator
(
start
,
maxDepth
,
options
);
return
new
DelegatingCloseableStream
<>(
iterator
,
StreamSupport
.
stream
(
Spliterators
.
spliteratorUnknownSize
(
iterator
,
Spliterator
.
DISTINCT
))
.
map
(
entry
->
entry
.
file
()));
Stream
<
Path
>
s
=
StreamSupport
.
stream
(
Spliterators
.
spliteratorUnknownSize
(
iterator
,
Spliterator
.
DISTINCT
),
false
).
map
(
entry
->
entry
.
file
());
return
new
DelegatingCloseableStream
<>(
iterator
,
s
);
}
/**
...
...
@@ -3455,10 +3459,13 @@ public final class Files {
throws
IOException
{
FileTreeIterator
iterator
=
new
FileTreeIterator
(
start
,
maxDepth
,
options
);
return
new
DelegatingCloseableStream
<>(
iterator
,
StreamSupport
.
stream
(
Spliterators
.
spliteratorUnknownSize
(
iterator
,
Spliterator
.
DISTINCT
))
.
filter
(
entry
->
matcher
.
test
(
entry
.
file
(),
entry
.
attributes
()))
.
map
(
entry
->
entry
.
file
()));
Stream
<
Path
>
s
=
StreamSupport
.
stream
(
Spliterators
.
spliteratorUnknownSize
(
iterator
,
Spliterator
.
DISTINCT
),
false
).
filter
(
entry
->
matcher
.
test
(
entry
.
file
(),
entry
.
attributes
())).
map
(
entry
->
entry
.
file
());
return
new
DelegatingCloseableStream
<>(
iterator
,
s
);
}
/**
...
...
src/share/classes/java/util/Arrays.java
浏览文件 @
6fd41038
...
...
@@ -4966,7 +4966,7 @@ public class Arrays {
* @since 1.8
*/
public
static
<
T
>
Stream
<
T
>
stream
(
T
[]
array
,
int
startInclusive
,
int
endExclusive
)
{
return
StreamSupport
.
stream
(
spliterator
(
array
,
startInclusive
,
endExclusive
));
return
StreamSupport
.
stream
(
spliterator
(
array
,
startInclusive
,
endExclusive
)
,
false
);
}
/**
...
...
@@ -4996,7 +4996,7 @@ public class Arrays {
* @since 1.8
*/
public
static
IntStream
stream
(
int
[]
array
,
int
startInclusive
,
int
endExclusive
)
{
return
StreamSupport
.
intStream
(
spliterator
(
array
,
startInclusive
,
endExclusive
));
return
StreamSupport
.
intStream
(
spliterator
(
array
,
startInclusive
,
endExclusive
)
,
false
);
}
/**
...
...
@@ -5026,7 +5026,7 @@ public class Arrays {
* @since 1.8
*/
public
static
LongStream
stream
(
long
[]
array
,
int
startInclusive
,
int
endExclusive
)
{
return
StreamSupport
.
longStream
(
spliterator
(
array
,
startInclusive
,
endExclusive
));
return
StreamSupport
.
longStream
(
spliterator
(
array
,
startInclusive
,
endExclusive
)
,
false
);
}
/**
...
...
@@ -5056,6 +5056,6 @@ public class Arrays {
* @since 1.8
*/
public
static
DoubleStream
stream
(
double
[]
array
,
int
startInclusive
,
int
endExclusive
)
{
return
StreamSupport
.
doubleStream
(
spliterator
(
array
,
startInclusive
,
endExclusive
));
return
StreamSupport
.
doubleStream
(
spliterator
(
array
,
startInclusive
,
endExclusive
)
,
false
);
}
}
src/share/classes/java/util/BitSet.java
浏览文件 @
6fd41038
...
...
@@ -1231,6 +1231,7 @@ public class BitSet implements Cloneable, java.io.Serializable {
new
BitSetIterator
(),
cardinality
(),
Spliterator
.
ORDERED
|
Spliterator
.
DISTINCT
|
Spliterator
.
SORTED
),
Spliterator
.
SIZED
|
Spliterator
.
SUBSIZED
|
Spliterator
.
ORDERED
|
Spliterator
.
DISTINCT
|
Spliterator
.
SORTED
);
Spliterator
.
ORDERED
|
Spliterator
.
DISTINCT
|
Spliterator
.
SORTED
,
false
);
}
}
src/share/classes/java/util/Collection.java
浏览文件 @
6fd41038
...
...
@@ -557,7 +557,7 @@ public interface Collection<E> extends Iterable<E> {
* @since 1.8
*/
default
Stream
<
E
>
stream
()
{
return
StreamSupport
.
stream
(
spliterator
());
return
StreamSupport
.
stream
(
spliterator
()
,
false
);
}
/**
...
...
@@ -578,6 +578,6 @@ public interface Collection<E> extends Iterable<E> {
* @since 1.8
*/
default
Stream
<
E
>
parallelStream
()
{
return
StreamSupport
.
parallelStream
(
spliterator
()
);
return
StreamSupport
.
stream
(
spliterator
(),
true
);
}
}
src/share/classes/java/util/Collections.java
浏览文件 @
6fd41038
...
...
@@ -1674,12 +1674,12 @@ public class Collections {
@Override
public
Stream
<
Entry
<
K
,
V
>>
stream
()
{
return
StreamSupport
.
stream
(
spliterator
());
return
StreamSupport
.
stream
(
spliterator
()
,
false
);
}
@Override
public
Stream
<
Entry
<
K
,
V
>>
parallelStream
()
{
return
StreamSupport
.
parallelStream
(
spliterator
()
);
return
StreamSupport
.
stream
(
spliterator
(),
true
);
}
public
Iterator
<
Map
.
Entry
<
K
,
V
>>
iterator
()
{
...
...
src/share/classes/java/util/jar/JarFile.java
浏览文件 @
6fd41038
...
...
@@ -272,7 +272,7 @@ class JarFile extends ZipFile {
return
StreamSupport
.
stream
(
Spliterators
.
spliterator
(
new
JarEntryIterator
(),
size
(),
Spliterator
.
ORDERED
|
Spliterator
.
DISTINCT
|
Spliterator
.
IMMUTABLE
|
Spliterator
.
NONNULL
));
Spliterator
.
IMMUTABLE
|
Spliterator
.
NONNULL
)
,
false
);
}
private
class
JarFileEntry
extends
JarEntry
{
...
...
src/share/classes/java/util/regex/Pattern.java
浏览文件 @
6fd41038
...
...
@@ -5815,6 +5815,6 @@ NEXT: while (i <= last) {
}
}
return
StreamSupport
.
stream
(
Spliterators
.
spliteratorUnknownSize
(
new
MatcherIterator
(),
Spliterator
.
ORDERED
|
Spliterator
.
NONNULL
));
new
MatcherIterator
(),
Spliterator
.
ORDERED
|
Spliterator
.
NONNULL
)
,
false
);
}
}
src/share/classes/java/util/stream/DoubleStream.java
浏览文件 @
6fd41038
...
...
@@ -672,7 +672,7 @@ public interface DoubleStream extends BaseStream<Double, DoubleStream> {
* @return an empty sequential stream
*/
public
static
DoubleStream
empty
()
{
return
StreamSupport
.
doubleStream
(
Spliterators
.
emptyDoubleSpliterator
());
return
StreamSupport
.
doubleStream
(
Spliterators
.
emptyDoubleSpliterator
()
,
false
);
}
/**
...
...
@@ -682,7 +682,7 @@ public interface DoubleStream extends BaseStream<Double, DoubleStream> {
* @return a singleton sequential stream
*/
public
static
DoubleStream
of
(
double
t
)
{
return
StreamSupport
.
doubleStream
(
new
Streams
.
DoubleStreamBuilderImpl
(
t
));
return
StreamSupport
.
doubleStream
(
new
Streams
.
DoubleStreamBuilderImpl
(
t
)
,
false
);
}
/**
...
...
@@ -730,7 +730,7 @@ public interface DoubleStream extends BaseStream<Double, DoubleStream> {
};
return
StreamSupport
.
doubleStream
(
Spliterators
.
spliteratorUnknownSize
(
iterator
,
Spliterator
.
ORDERED
|
Spliterator
.
IMMUTABLE
|
Spliterator
.
NONNULL
));
Spliterator
.
ORDERED
|
Spliterator
.
IMMUTABLE
|
Spliterator
.
NONNULL
)
,
false
);
}
/**
...
...
@@ -744,7 +744,7 @@ public interface DoubleStream extends BaseStream<Double, DoubleStream> {
public
static
DoubleStream
generate
(
DoubleSupplier
s
)
{
Objects
.
requireNonNull
(
s
);
return
StreamSupport
.
doubleStream
(
new
StreamSpliterators
.
InfiniteSupplyingSpliterator
.
OfDouble
(
Long
.
MAX_VALUE
,
s
));
new
StreamSpliterators
.
InfiniteSupplyingSpliterator
.
OfDouble
(
Long
.
MAX_VALUE
,
s
)
,
false
);
}
/**
...
...
@@ -764,8 +764,6 @@ public interface DoubleStream extends BaseStream<Double, DoubleStream> {
Spliterator
.
OfDouble
split
=
new
Streams
.
ConcatSpliterator
.
OfDouble
(
a
.
spliterator
(),
b
.
spliterator
());
return
(
a
.
isParallel
()
||
b
.
isParallel
())
?
StreamSupport
.
doubleParallelStream
(
split
)
:
StreamSupport
.
doubleStream
(
split
);
return
StreamSupport
.
doubleStream
(
split
,
a
.
isParallel
()
||
b
.
isParallel
());
}
}
src/share/classes/java/util/stream/IntStream.java
浏览文件 @
6fd41038
...
...
@@ -674,7 +674,7 @@ public interface IntStream extends BaseStream<Integer, IntStream> {
* @return an empty sequential stream
*/
public
static
IntStream
empty
()
{
return
StreamSupport
.
intStream
(
Spliterators
.
emptyIntSpliterator
());
return
StreamSupport
.
intStream
(
Spliterators
.
emptyIntSpliterator
()
,
false
);
}
/**
...
...
@@ -684,7 +684,7 @@ public interface IntStream extends BaseStream<Integer, IntStream> {
* @return a singleton sequential stream
*/
public
static
IntStream
of
(
int
t
)
{
return
StreamSupport
.
intStream
(
new
Streams
.
IntStreamBuilderImpl
(
t
));
return
StreamSupport
.
intStream
(
new
Streams
.
IntStreamBuilderImpl
(
t
)
,
false
);
}
/**
...
...
@@ -732,7 +732,7 @@ public interface IntStream extends BaseStream<Integer, IntStream> {
};
return
StreamSupport
.
intStream
(
Spliterators
.
spliteratorUnknownSize
(
iterator
,
Spliterator
.
ORDERED
|
Spliterator
.
IMMUTABLE
|
Spliterator
.
NONNULL
));
Spliterator
.
ORDERED
|
Spliterator
.
IMMUTABLE
|
Spliterator
.
NONNULL
)
,
false
);
}
/**
...
...
@@ -746,7 +746,7 @@ public interface IntStream extends BaseStream<Integer, IntStream> {
public
static
IntStream
generate
(
IntSupplier
s
)
{
Objects
.
requireNonNull
(
s
);
return
StreamSupport
.
intStream
(
new
StreamSpliterators
.
InfiniteSupplyingSpliterator
.
OfInt
(
Long
.
MAX_VALUE
,
s
));
new
StreamSpliterators
.
InfiniteSupplyingSpliterator
.
OfInt
(
Long
.
MAX_VALUE
,
s
)
,
false
);
}
/**
...
...
@@ -771,7 +771,7 @@ public interface IntStream extends BaseStream<Integer, IntStream> {
return
empty
();
}
else
{
return
StreamSupport
.
intStream
(
new
Streams
.
RangeIntSpliterator
(
startInclusive
,
endExclusive
,
false
));
new
Streams
.
RangeIntSpliterator
(
startInclusive
,
endExclusive
,
false
)
,
false
);
}
}
...
...
@@ -797,7 +797,7 @@ public interface IntStream extends BaseStream<Integer, IntStream> {
return
empty
();
}
else
{
return
StreamSupport
.
intStream
(
new
Streams
.
RangeIntSpliterator
(
startInclusive
,
endInclusive
,
true
));
new
Streams
.
RangeIntSpliterator
(
startInclusive
,
endInclusive
,
true
)
,
false
);
}
}
...
...
@@ -818,8 +818,6 @@ public interface IntStream extends BaseStream<Integer, IntStream> {
Spliterator
.
OfInt
split
=
new
Streams
.
ConcatSpliterator
.
OfInt
(
a
.
spliterator
(),
b
.
spliterator
());
return
(
a
.
isParallel
()
||
b
.
isParallel
())
?
StreamSupport
.
intParallelStream
(
split
)
:
StreamSupport
.
intStream
(
split
);
return
StreamSupport
.
intStream
(
split
,
a
.
isParallel
()
||
b
.
isParallel
());
}
}
src/share/classes/java/util/stream/LongStream.java
浏览文件 @
6fd41038
...
...
@@ -665,7 +665,7 @@ public interface LongStream extends BaseStream<Long, LongStream> {
* @return an empty sequential stream
*/
public
static
LongStream
empty
()
{
return
StreamSupport
.
longStream
(
Spliterators
.
emptyLongSpliterator
());
return
StreamSupport
.
longStream
(
Spliterators
.
emptyLongSpliterator
()
,
false
);
}
/**
...
...
@@ -675,7 +675,7 @@ public interface LongStream extends BaseStream<Long, LongStream> {
* @return a singleton sequential stream
*/
public
static
LongStream
of
(
long
t
)
{
return
StreamSupport
.
longStream
(
new
Streams
.
LongStreamBuilderImpl
(
t
));
return
StreamSupport
.
longStream
(
new
Streams
.
LongStreamBuilderImpl
(
t
)
,
false
);
}
/**
...
...
@@ -723,7 +723,7 @@ public interface LongStream extends BaseStream<Long, LongStream> {
};
return
StreamSupport
.
longStream
(
Spliterators
.
spliteratorUnknownSize
(
iterator
,
Spliterator
.
ORDERED
|
Spliterator
.
IMMUTABLE
|
Spliterator
.
NONNULL
));
Spliterator
.
ORDERED
|
Spliterator
.
IMMUTABLE
|
Spliterator
.
NONNULL
)
,
false
);
}
/**
...
...
@@ -737,7 +737,7 @@ public interface LongStream extends BaseStream<Long, LongStream> {
public
static
LongStream
generate
(
LongSupplier
s
)
{
Objects
.
requireNonNull
(
s
);
return
StreamSupport
.
longStream
(
new
StreamSpliterators
.
InfiniteSupplyingSpliterator
.
OfLong
(
Long
.
MAX_VALUE
,
s
));
new
StreamSpliterators
.
InfiniteSupplyingSpliterator
.
OfLong
(
Long
.
MAX_VALUE
,
s
)
,
false
);
}
/**
...
...
@@ -769,7 +769,7 @@ public interface LongStream extends BaseStream<Long, LongStream> {
return
concat
(
range
(
startInclusive
,
m
),
range
(
m
,
endExclusive
));
}
else
{
return
StreamSupport
.
longStream
(
new
Streams
.
RangeLongSpliterator
(
startInclusive
,
endExclusive
,
false
));
new
Streams
.
RangeLongSpliterator
(
startInclusive
,
endExclusive
,
false
)
,
false
);
}
}
...
...
@@ -803,7 +803,7 @@ public interface LongStream extends BaseStream<Long, LongStream> {
return
concat
(
range
(
startInclusive
,
m
),
rangeClosed
(
m
,
endInclusive
));
}
else
{
return
StreamSupport
.
longStream
(
new
Streams
.
RangeLongSpliterator
(
startInclusive
,
endInclusive
,
true
));
new
Streams
.
RangeLongSpliterator
(
startInclusive
,
endInclusive
,
true
)
,
false
);
}
}
...
...
@@ -824,8 +824,6 @@ public interface LongStream extends BaseStream<Long, LongStream> {
Spliterator
.
OfLong
split
=
new
Streams
.
ConcatSpliterator
.
OfLong
(
a
.
spliterator
(),
b
.
spliterator
());
return
(
a
.
isParallel
()
||
b
.
isParallel
())
?
StreamSupport
.
longParallelStream
(
split
)
:
StreamSupport
.
longStream
(
split
);
return
StreamSupport
.
longStream
(
split
,
a
.
isParallel
()
||
b
.
isParallel
());
}
}
src/share/classes/java/util/stream/Stream.java
浏览文件 @
6fd41038
...
...
@@ -805,7 +805,7 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
* @return an empty sequential stream
*/
public
static
<
T
>
Stream
<
T
>
empty
()
{
return
StreamSupport
.
stream
(
Spliterators
.<
T
>
emptySpliterator
());
return
StreamSupport
.
stream
(
Spliterators
.<
T
>
emptySpliterator
()
,
false
);
}
/**
...
...
@@ -816,7 +816,7 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
* @return a singleton sequential stream
*/
public
static
<
T
>
Stream
<
T
>
of
(
T
t
)
{
return
StreamSupport
.
stream
(
new
Streams
.
StreamBuilderImpl
<>(
t
));
return
StreamSupport
.
stream
(
new
Streams
.
StreamBuilderImpl
<>(
t
)
,
false
);
}
/**
...
...
@@ -866,7 +866,7 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
};
return
StreamSupport
.
stream
(
Spliterators
.
spliteratorUnknownSize
(
iterator
,
Spliterator
.
ORDERED
|
Spliterator
.
IMMUTABLE
));
Spliterator
.
ORDERED
|
Spliterator
.
IMMUTABLE
)
,
false
);
}
/**
...
...
@@ -881,7 +881,7 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
public
static
<
T
>
Stream
<
T
>
generate
(
Supplier
<
T
>
s
)
{
Objects
.
requireNonNull
(
s
);
return
StreamSupport
.
stream
(
new
StreamSpliterators
.
InfiniteSupplyingSpliterator
.
OfRef
<>(
Long
.
MAX_VALUE
,
s
));
new
StreamSpliterators
.
InfiniteSupplyingSpliterator
.
OfRef
<>(
Long
.
MAX_VALUE
,
s
)
,
false
);
}
/**
...
...
@@ -904,8 +904,6 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
@SuppressWarnings
(
"unchecked"
)
Spliterator
<
T
>
split
=
new
Streams
.
ConcatSpliterator
.
OfRef
<>(
(
Spliterator
<
T
>)
a
.
spliterator
(),
(
Spliterator
<
T
>)
b
.
spliterator
());
return
(
a
.
isParallel
()
||
b
.
isParallel
())
?
StreamSupport
.
parallelStream
(
split
)
:
StreamSupport
.
stream
(
split
);
return
StreamSupport
.
stream
(
split
,
a
.
isParallel
()
||
b
.
isParallel
());
}
}
src/share/classes/java/util/stream/StreamSupport.java
浏览文件 @
6fd41038
此差异已折叠。
点击以展开。
src/share/classes/java/util/stream/Streams.java
浏览文件 @
6fd41038
...
...
@@ -25,10 +25,7 @@
package
java.util.stream
;
import
java.util.Comparator
;
import
java.util.Objects
;
import
java.util.Spliterator
;
import
java.util.Spliterators
;
import
java.util.function.BiFunction
;
import
java.util.function.Consumer
;
import
java.util.function.DoubleConsumer
;
import
java.util.function.IntConsumer
;
...
...
@@ -379,7 +376,7 @@ final class Streams {
count
=
-
count
-
1
;
// Use this spliterator if 0 or 1 elements, otherwise use
// the spliterator of the spined buffer
return
(
c
<
2
)
?
StreamSupport
.
stream
(
this
)
:
StreamSupport
.
stream
(
buffer
.
spliterator
()
);
return
(
c
<
2
)
?
StreamSupport
.
stream
(
this
,
false
)
:
StreamSupport
.
stream
(
buffer
.
spliterator
(),
false
);
}
throw
new
IllegalStateException
();
...
...
@@ -466,7 +463,7 @@ final class Streams {
count
=
-
count
-
1
;
// Use this spliterator if 0 or 1 elements, otherwise use
// the spliterator of the spined buffer
return
(
c
<
2
)
?
StreamSupport
.
intStream
(
this
)
:
StreamSupport
.
intStream
(
buffer
.
spliterator
()
);
return
(
c
<
2
)
?
StreamSupport
.
intStream
(
this
,
false
)
:
StreamSupport
.
intStream
(
buffer
.
spliterator
(),
false
);
}
throw
new
IllegalStateException
();
...
...
@@ -553,7 +550,7 @@ final class Streams {
count
=
-
count
-
1
;
// Use this spliterator if 0 or 1 elements, otherwise use
// the spliterator of the spined buffer
return
(
c
<
2
)
?
StreamSupport
.
longStream
(
this
)
:
StreamSupport
.
longStream
(
buffer
.
spliterator
()
);
return
(
c
<
2
)
?
StreamSupport
.
longStream
(
this
,
false
)
:
StreamSupport
.
longStream
(
buffer
.
spliterator
(),
false
);
}
throw
new
IllegalStateException
();
...
...
@@ -640,7 +637,7 @@ final class Streams {
count
=
-
count
-
1
;
// Use this spliterator if 0 or 1 elements, otherwise use
// the spliterator of the spined buffer
return
(
c
<
2
)
?
StreamSupport
.
doubleStream
(
this
)
:
StreamSupport
.
doubleStream
(
buffer
.
spliterator
()
);
return
(
c
<
2
)
?
StreamSupport
.
doubleStream
(
this
,
false
)
:
StreamSupport
.
doubleStream
(
buffer
.
spliterator
(),
false
);
}
throw
new
IllegalStateException
();
...
...
src/share/classes/java/util/zip/ZipFile.java
浏览文件 @
6fd41038
...
...
@@ -551,7 +551,7 @@ class ZipFile implements ZipConstants, Closeable {
return
StreamSupport
.
stream
(
Spliterators
.
spliterator
(
new
ZipEntryIterator
(),
size
(),
Spliterator
.
ORDERED
|
Spliterator
.
DISTINCT
|
Spliterator
.
IMMUTABLE
|
Spliterator
.
NONNULL
));
Spliterator
.
IMMUTABLE
|
Spliterator
.
NONNULL
)
,
false
);
}
private
ZipEntry
getZipEntry
(
String
name
,
long
jzentry
)
{
...
...
test/java/util/stream/bootlib/java/util/stream/DoubleStreamTestScenario.java
浏览文件 @
6fd41038
...
...
@@ -140,9 +140,9 @@ public enum DoubleStreamTestScenario implements OpTestCase.BaseStreamTestScenari
void
_run
(
TestData
<
T
,
S_IN
>
data
,
DoubleConsumer
b
,
Function
<
S_IN
,
DoubleStream
>
m
)
{
DoubleStream
s
=
m
.
apply
(
data
.
parallelStream
());
Spliterator
.
OfDouble
sp
=
s
.
spliterator
();
DoubleStream
ss
=
StreamSupport
.
double
Parallel
Stream
(()
->
sp
,
StreamOpFlag
.
toCharacteristics
(
OpTestCase
.
getStreamFlags
(
s
))
|
(
sp
.
getExactSizeIfKnown
()
<
0
?
0
:
Spliterator
.
SIZED
)
);
DoubleStream
ss
=
StreamSupport
.
doubleStream
(()
->
sp
,
StreamOpFlag
.
toCharacteristics
(
OpTestCase
.
getStreamFlags
(
s
))
|
(
sp
.
getExactSizeIfKnown
()
<
0
?
0
:
Spliterator
.
SIZED
),
true
);
for
(
double
t
:
ss
.
toArray
())
b
.
accept
(
t
);
}
...
...
test/java/util/stream/bootlib/java/util/stream/IntStreamTestScenario.java
浏览文件 @
6fd41038
...
...
@@ -140,9 +140,10 @@ public enum IntStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
void
_run
(
TestData
<
T
,
S_IN
>
data
,
IntConsumer
b
,
Function
<
S_IN
,
IntStream
>
m
)
{
IntStream
s
=
m
.
apply
(
data
.
parallelStream
());
Spliterator
.
OfInt
sp
=
s
.
spliterator
();
IntStream
ss
=
StreamSupport
.
intParallelStream
(()
->
sp
,
StreamOpFlag
.
toCharacteristics
(
OpTestCase
.
getStreamFlags
(
s
))
|
(
sp
.
getExactSizeIfKnown
()
<
0
?
0
:
Spliterator
.
SIZED
));
IntStream
ss
=
StreamSupport
.
intStream
(()
->
sp
,
StreamOpFlag
.
toCharacteristics
(
OpTestCase
.
getStreamFlags
(
s
))
|
(
sp
.
getExactSizeIfKnown
()
<
0
?
0
:
Spliterator
.
SIZED
),
true
);
for
(
int
t
:
ss
.
toArray
())
b
.
accept
(
t
);
}
...
...
test/java/util/stream/bootlib/java/util/stream/LongStreamTestScenario.java
浏览文件 @
6fd41038
...
...
@@ -140,9 +140,9 @@ public enum LongStreamTestScenario implements OpTestCase.BaseStreamTestScenario
void
_run
(
TestData
<
T
,
S_IN
>
data
,
LongConsumer
b
,
Function
<
S_IN
,
LongStream
>
m
)
{
LongStream
s
=
m
.
apply
(
data
.
parallelStream
());
Spliterator
.
OfLong
sp
=
s
.
spliterator
();
LongStream
ss
=
StreamSupport
.
long
Parallel
Stream
(()
->
sp
,
StreamOpFlag
.
toCharacteristics
(
OpTestCase
.
getStreamFlags
(
s
))
|
(
sp
.
getExactSizeIfKnown
()
<
0
?
0
:
Spliterator
.
SIZED
)
);
LongStream
ss
=
StreamSupport
.
longStream
(()
->
sp
,
StreamOpFlag
.
toCharacteristics
(
OpTestCase
.
getStreamFlags
(
s
))
|
(
sp
.
getExactSizeIfKnown
()
<
0
?
0
:
Spliterator
.
SIZED
),
true
);
for
(
long
t
:
ss
.
toArray
())
b
.
accept
(
t
);
}
...
...
test/java/util/stream/bootlib/java/util/stream/StreamTestScenario.java
浏览文件 @
6fd41038
...
...
@@ -151,9 +151,9 @@ public enum StreamTestScenario implements OpTestCase.BaseStreamTestScenario {
void
_run
(
TestData
<
T
,
S_IN
>
data
,
Consumer
<
U
>
b
,
Function
<
S_IN
,
Stream
<
U
>>
m
)
{
Stream
<
U
>
s
=
m
.
apply
(
data
.
parallelStream
());
Spliterator
<
U
>
sp
=
s
.
spliterator
();
Stream
<
U
>
ss
=
StreamSupport
.
parallelS
tream
(()
->
sp
,
StreamOpFlag
.
toCharacteristics
(
OpTestCase
.
getStreamFlags
(
s
))
|
(
sp
.
getExactSizeIfKnown
()
<
0
?
0
:
Spliterator
.
SIZED
)
);
Stream
<
U
>
ss
=
StreamSupport
.
s
tream
(()
->
sp
,
StreamOpFlag
.
toCharacteristics
(
OpTestCase
.
getStreamFlags
(
s
))
|
(
sp
.
getExactSizeIfKnown
()
<
0
?
0
:
Spliterator
.
SIZED
),
true
);
for
(
Object
t
:
ss
.
toArray
())
b
.
accept
((
U
)
t
);
}
...
...
test/java/util/stream/bootlib/java/util/stream/TestData.java
浏览文件 @
6fd41038
...
...
@@ -87,8 +87,8 @@ public interface TestData<T, S extends BaseStream<T, S>>
public
static
<
T
>
OfRef
<
T
>
ofSpinedBuffer
(
String
name
,
SpinedBuffer
<
T
>
buffer
)
{
return
new
AbstractTestData
.
RefTestData
<>(
name
,
buffer
,
b
->
StreamSupport
.
stream
(
b
.
spliterator
()),
b
->
StreamSupport
.
parallelStream
(
b
.
spliterator
()
),
b
->
StreamSupport
.
stream
(
b
.
spliterator
()
,
false
),
b
->
StreamSupport
.
stream
(
b
.
spliterator
(),
true
),
SpinedBuffer:
:
spliterator
,
b
->
(
int
)
b
.
count
());
}
...
...
@@ -103,8 +103,8 @@ public interface TestData<T, S extends BaseStream<T, S>>
public
static
<
T
>
OfRef
<
T
>
ofRefNode
(
String
name
,
Node
<
T
>
node
)
{
return
new
AbstractTestData
.
RefTestData
<>(
name
,
node
,
n
->
StreamSupport
.
stream
(
n:
:
spliterator
,
Spliterator
.
SIZED
|
Spliterator
.
ORDERED
),
n
->
StreamSupport
.
parallelStream
(
n:
:
spliterator
,
Spliterator
.
SIZED
|
Spliterator
.
ORDERED
),
n
->
StreamSupport
.
stream
(
n:
:
spliterator
,
Spliterator
.
SIZED
|
Spliterator
.
ORDERED
,
false
),
n
->
StreamSupport
.
stream
(
n:
:
spliterator
,
Spliterator
.
SIZED
|
Spliterator
.
ORDERED
,
true
),
Node:
:
spliterator
,
n
->
(
int
)
n
.
count
());
}
...
...
@@ -117,8 +117,8 @@ public interface TestData<T, S extends BaseStream<T, S>>
public
static
OfInt
ofSpinedBuffer
(
String
name
,
SpinedBuffer
.
OfInt
buffer
)
{
return
new
AbstractTestData
.
IntTestData
<>(
name
,
buffer
,
b
->
StreamSupport
.
intStream
(
b
.
spliterator
()),
b
->
StreamSupport
.
int
ParallelStream
(
b
.
spliterator
()
),
b
->
StreamSupport
.
intStream
(
b
.
spliterator
()
,
false
),
b
->
StreamSupport
.
int
Stream
(
b
.
spliterator
(),
true
),
SpinedBuffer
.
OfInt
::
spliterator
,
b
->
(
int
)
b
.
count
());
}
...
...
@@ -134,8 +134,8 @@ public interface TestData<T, S extends BaseStream<T, S>>
public
static
OfInt
ofNode
(
String
name
,
Node
.
OfInt
node
)
{
int
characteristics
=
Spliterator
.
SIZED
|
Spliterator
.
ORDERED
;
return
new
AbstractTestData
.
IntTestData
<>(
name
,
node
,
n
->
StreamSupport
.
intStream
(
n:
:
spliterator
,
characteristics
),
n
->
StreamSupport
.
int
ParallelStream
(
n:
:
spliterator
,
characteristics
),
n
->
StreamSupport
.
intStream
(
n:
:
spliterator
,
characteristics
,
false
),
n
->
StreamSupport
.
int
Stream
(
n:
:
spliterator
,
characteristics
,
true
),
Node
.
OfInt
::
spliterator
,
n
->
(
int
)
n
.
count
());
}
...
...
@@ -148,8 +148,8 @@ public interface TestData<T, S extends BaseStream<T, S>>
public
static
OfLong
ofSpinedBuffer
(
String
name
,
SpinedBuffer
.
OfLong
buffer
)
{
return
new
AbstractTestData
.
LongTestData
<>(
name
,
buffer
,
b
->
StreamSupport
.
longStream
(
b
.
spliterator
()),
b
->
StreamSupport
.
long
ParallelStream
(
b
.
spliterator
()
),
b
->
StreamSupport
.
longStream
(
b
.
spliterator
()
,
false
),
b
->
StreamSupport
.
long
Stream
(
b
.
spliterator
(),
true
),
SpinedBuffer
.
OfLong
::
spliterator
,
b
->
(
int
)
b
.
count
());
}
...
...
@@ -165,8 +165,8 @@ public interface TestData<T, S extends BaseStream<T, S>>
public
static
OfLong
ofNode
(
String
name
,
Node
.
OfLong
node
)
{
int
characteristics
=
Spliterator
.
SIZED
|
Spliterator
.
ORDERED
;
return
new
AbstractTestData
.
LongTestData
<>(
name
,
node
,
n
->
StreamSupport
.
longStream
(
n:
:
spliterator
,
characteristics
),
n
->
StreamSupport
.
long
ParallelStream
(
n:
:
spliterator
,
characteristics
),
n
->
StreamSupport
.
longStream
(
n:
:
spliterator
,
characteristics
,
false
),
n
->
StreamSupport
.
long
Stream
(
n:
:
spliterator
,
characteristics
,
true
),
Node
.
OfLong
::
spliterator
,
n
->
(
int
)
n
.
count
());
}
...
...
@@ -179,8 +179,8 @@ public interface TestData<T, S extends BaseStream<T, S>>
public
static
OfDouble
ofSpinedBuffer
(
String
name
,
SpinedBuffer
.
OfDouble
buffer
)
{
return
new
AbstractTestData
.
DoubleTestData
<>(
name
,
buffer
,
b
->
StreamSupport
.
doubleStream
(
b
.
spliterator
()),
b
->
StreamSupport
.
double
ParallelStream
(
b
.
spliterator
()
),
b
->
StreamSupport
.
doubleStream
(
b
.
spliterator
()
,
false
),
b
->
StreamSupport
.
double
Stream
(
b
.
spliterator
(),
true
),
SpinedBuffer
.
OfDouble
::
spliterator
,
b
->
(
int
)
b
.
count
());
}
...
...
@@ -196,8 +196,8 @@ public interface TestData<T, S extends BaseStream<T, S>>
public
static
OfDouble
ofNode
(
String
name
,
Node
.
OfDouble
node
)
{
int
characteristics
=
Spliterator
.
SIZED
|
Spliterator
.
ORDERED
;
return
new
AbstractTestData
.
DoubleTestData
<>(
name
,
node
,
n
->
StreamSupport
.
doubleStream
(
n:
:
spliterator
,
characteristics
),
n
->
StreamSupport
.
double
ParallelStream
(
n:
:
spliterator
,
characteristics
),
n
->
StreamSupport
.
doubleStream
(
n:
:
spliterator
,
characteristics
,
false
),
n
->
StreamSupport
.
double
Stream
(
n:
:
spliterator
,
characteristics
,
true
),
Node
.
OfDouble
::
spliterator
,
n
->
(
int
)
n
.
count
());
}
...
...
test/java/util/stream/test/org/openjdk/tests/java/util/stream/DistinctOpTest.java
浏览文件 @
6fd41038
...
...
@@ -86,8 +86,8 @@ public class DistinctOpTest extends OpTestCase {
static
class
SortedTestData
<
T
>
extends
TestData
.
AbstractTestData
.
RefTestData
<
T
,
List
<
T
>>
{
SortedTestData
(
List
<
T
>
coll
)
{
super
(
"SortedTestData"
,
coll
,
c
->
StreamSupport
.
stream
(
Spliterators
.
spliterator
(
c
.
toArray
(),
Spliterator
.
ORDERED
|
Spliterator
.
SORTED
)),
c
->
StreamSupport
.
parallelStream
(
Spliterators
.
spliterator
(
c
.
toArray
(),
Spliterator
.
ORDERED
|
Spliterator
.
SORTED
)
),
c
->
StreamSupport
.
stream
(
Spliterators
.
spliterator
(
c
.
toArray
(),
Spliterator
.
ORDERED
|
Spliterator
.
SORTED
)
,
false
),
c
->
StreamSupport
.
stream
(
Spliterators
.
spliterator
(
c
.
toArray
(),
Spliterator
.
ORDERED
|
Spliterator
.
SORTED
),
true
),
c
->
Spliterators
.
spliterator
(
c
.
toArray
(),
Spliterator
.
ORDERED
|
Spliterator
.
SORTED
),
List:
:
size
);
}
...
...
test/java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest.java
浏览文件 @
6fd41038
...
...
@@ -306,7 +306,7 @@ public class InfiniteStreamWithLimitOpTest extends OpTestCase {
private
TestData
.
OfLong
proxiedLongRange
(
long
l
,
long
u
)
{
return
TestData
.
Factory
.
ofLongSupplier
(
String
.
format
(
"[%d, %d)"
,
l
,
u
),
()
->
StreamSupport
.
longStream
(
proxyNotSubsized
(
LongStream
.
range
(
l
,
u
).
spliterator
())));
()
->
StreamSupport
.
longStream
(
proxyNotSubsized
(
LongStream
.
range
(
l
,
u
).
spliterator
())
,
false
));
}
@Test
(
dataProvider
=
"Stream.limit"
)
...
...
test/java/util/stream/test/org/openjdk/tests/java/util/stream/MatchOpTest.java
浏览文件 @
6fd41038
...
...
@@ -155,7 +155,7 @@ public class MatchOpTest extends OpTestCase {
}
Supplier
<
Iterator
<
Integer
>>
source
=
()
->
Arrays
.
asList
(
1
,
2
,
3
,
4
).
iterator
();
Supplier
<
Stream
<
Integer
>>
s
=
()
->
StreamSupport
.
stream
(
Spliterators
.
spliteratorUnknownSize
(
new
CycleIterator
(
source
),
0
));
Supplier
<
Stream
<
Integer
>>
s
=
()
->
StreamSupport
.
stream
(
Spliterators
.
spliteratorUnknownSize
(
new
CycleIterator
(
source
),
0
)
,
false
);
assertFalse
(
s
.
get
().
allMatch
(
i
->
i
>
3
));
assertTrue
(
s
.
get
().
anyMatch
(
i
->
i
>
3
));
...
...
@@ -240,7 +240,7 @@ public class MatchOpTest extends OpTestCase {
}
Supplier
<
PrimitiveIterator
.
OfInt
>
source
=
()
->
Arrays
.
stream
(
new
int
[]{
1
,
2
,
3
,
4
}).
iterator
();
Supplier
<
IntStream
>
s
=
()
->
StreamSupport
.
intStream
(
Spliterators
.
spliteratorUnknownSize
(
new
CycleIterator
(
source
),
0
));
Supplier
<
IntStream
>
s
=
()
->
StreamSupport
.
intStream
(
Spliterators
.
spliteratorUnknownSize
(
new
CycleIterator
(
source
),
0
)
,
false
);
assertFalse
(
s
.
get
().
allMatch
(
i
->
i
>
3
));
assertTrue
(
s
.
get
().
anyMatch
(
i
->
i
>
3
));
...
...
@@ -325,7 +325,7 @@ public class MatchOpTest extends OpTestCase {
}
Supplier
<
PrimitiveIterator
.
OfLong
>
source
=
()
->
Arrays
.
stream
(
new
long
[]{
1
,
2
,
3
,
4
}).
iterator
();
Supplier
<
LongStream
>
s
=
()
->
StreamSupport
.
longStream
(
Spliterators
.
spliteratorUnknownSize
(
new
CycleIterator
(
source
),
0
));
Supplier
<
LongStream
>
s
=
()
->
StreamSupport
.
longStream
(
Spliterators
.
spliteratorUnknownSize
(
new
CycleIterator
(
source
),
0
)
,
false
);
assertFalse
(
s
.
get
().
allMatch
(
i
->
i
>
3
));
assertTrue
(
s
.
get
().
anyMatch
(
i
->
i
>
3
));
...
...
@@ -410,7 +410,7 @@ public class MatchOpTest extends OpTestCase {
}
Supplier
<
PrimitiveIterator
.
OfDouble
>
source
=
()
->
Arrays
.
stream
(
new
double
[]{
1
,
2
,
3
,
4
}).
iterator
();
Supplier
<
DoubleStream
>
s
=
()
->
StreamSupport
.
doubleStream
(
Spliterators
.
spliteratorUnknownSize
(
new
CycleIterator
(
source
),
0
));
Supplier
<
DoubleStream
>
s
=
()
->
StreamSupport
.
doubleStream
(
Spliterators
.
spliteratorUnknownSize
(
new
CycleIterator
(
source
),
0
)
,
false
);
assertFalse
(
s
.
get
().
allMatch
(
i
->
i
>
3
));
assertTrue
(
s
.
get
().
anyMatch
(
i
->
i
>
3
));
...
...
test/java/util/stream/test/org/openjdk/tests/java/util/stream/SliceOpTest.java
浏览文件 @
6fd41038
...
...
@@ -237,7 +237,7 @@ public class SliceOpTest extends OpTestCase {
List
<
Integer
>
list
=
IntStream
.
range
(
0
,
100
).
boxed
().
collect
(
Collectors
.
toList
());
TestData
.
OfRef
<
Integer
>
data
=
TestData
.
Factory
.
ofSupplier
(
"Non splitting, not SUBSIZED, ORDERED, stream"
,
()
->
StreamSupport
.
stream
(
new
NonSplittingNotSubsizedOrderedSpliterator
<>(
list
.
spliterator
())));
()
->
StreamSupport
.
stream
(
new
NonSplittingNotSubsizedOrderedSpliterator
<>(
list
.
spliterator
())
,
false
));
testSkipLimitOps
(
"testSkipLimitOpsWithNonSplittingSpliterator"
,
data
);
}
...
...
test/java/util/stream/test/org/openjdk/tests/java/util/stream/SortedOpTest.java
浏览文件 @
6fd41038
...
...
@@ -78,7 +78,7 @@ public class SortedOpTest extends OpTestCase {
}
private
<
T
>
Stream
<
T
>
unknownSizeStream
(
List
<
T
>
l
)
{
return
StreamSupport
.
stream
(
Spliterators
.
spliteratorUnknownSize
(
l
.
iterator
(),
0
));
return
StreamSupport
.
stream
(
Spliterators
.
spliteratorUnknownSize
(
l
.
iterator
(),
0
)
,
false
);
}
@Test
(
dataProvider
=
"StreamTestData<Integer>"
,
dataProviderClass
=
StreamTestDataProvider
.
class
)
...
...
@@ -150,7 +150,7 @@ public class SortedOpTest extends OpTestCase {
}
private
IntStream
unknownSizeIntStream
(
int
[]
a
)
{
return
StreamSupport
.
intStream
(
Spliterators
.
spliteratorUnknownSize
(
Spliterators
.
iterator
(
Arrays
.
spliterator
(
a
)),
0
));
return
StreamSupport
.
intStream
(
Spliterators
.
spliteratorUnknownSize
(
Spliterators
.
iterator
(
Arrays
.
spliterator
(
a
)),
0
)
,
false
);
}
@Test
(
dataProvider
=
"IntStreamTestData"
,
dataProviderClass
=
IntStreamTestDataProvider
.
class
)
...
...
@@ -193,7 +193,7 @@ public class SortedOpTest extends OpTestCase {
}
private
LongStream
unknownSizeLongStream
(
long
[]
a
)
{
return
StreamSupport
.
longStream
(
Spliterators
.
spliteratorUnknownSize
(
Spliterators
.
iterator
(
Arrays
.
spliterator
(
a
)),
0
));
return
StreamSupport
.
longStream
(
Spliterators
.
spliteratorUnknownSize
(
Spliterators
.
iterator
(
Arrays
.
spliterator
(
a
)),
0
)
,
false
);
}
@Test
(
dataProvider
=
"LongStreamTestData"
,
dataProviderClass
=
LongStreamTestDataProvider
.
class
)
...
...
@@ -236,7 +236,7 @@ public class SortedOpTest extends OpTestCase {
}
private
DoubleStream
unknownSizeDoubleStream
(
double
[]
a
)
{
return
StreamSupport
.
doubleStream
(
Spliterators
.
spliteratorUnknownSize
(
Spliterators
.
iterator
(
Arrays
.
spliterator
(
a
)),
0
));
return
StreamSupport
.
doubleStream
(
Spliterators
.
spliteratorUnknownSize
(
Spliterators
.
iterator
(
Arrays
.
spliterator
(
a
)),
0
)
,
false
);
}
@Test
(
dataProvider
=
"DoubleStreamTestData"
,
dataProviderClass
=
DoubleStreamTestDataProvider
.
class
)
...
...
test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java
浏览文件 @
6fd41038
...
...
@@ -266,7 +266,7 @@ public class StreamSpliteratorTest extends OpTestCase {
setContext
(
"proxyEstimateSize"
,
proxyEstimateSize
);
Spliterator
<
Integer
>
sp
=
intermediateOp
.
apply
(
l
.
stream
()).
spliterator
();
ProxyNoExactSizeSpliterator
<
Integer
>
psp
=
new
ProxyNoExactSizeSpliterator
<>(
sp
,
proxyEstimateSize
);
Stream
<
Integer
>
s
=
StreamSupport
.
parallelStream
(
psp
);
Stream
<
Integer
>
s
=
StreamSupport
.
stream
(
psp
,
true
);
terminalOp
.
accept
(
s
);
Assert
.
assertTrue
(
psp
.
splits
>
0
,
String
.
format
(
"Number of splits should be greater that zero when proxyEstimateSize is %s"
,
...
...
@@ -290,14 +290,14 @@ public class StreamSpliteratorTest extends OpTestCase {
withData
(
data
).
stream
((
Stream
<
Integer
>
in
)
->
{
Stream
<
Integer
>
out
=
f
.
apply
(
in
);
return
StreamSupport
.
stream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
));
return
StreamSupport
.
stream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
)
,
false
);
}).
exercise
();
withData
(
data
).
stream
((
Stream
<
Integer
>
in
)
->
{
Stream
<
Integer
>
out
=
f
.
apply
(
in
);
return
StreamSupport
.
parallelStream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
)
);
return
StreamSupport
.
stream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
),
true
);
}).
exercise
();
}
...
...
@@ -362,7 +362,7 @@ public class StreamSpliteratorTest extends OpTestCase {
// @@@ Need way to obtain the target size
Spliterator
.
OfInt
sp
=
intermediateOp
.
apply
(
IntStream
.
range
(
0
,
1000
)).
spliterator
();
ProxyNoExactSizeSpliterator
.
OfInt
psp
=
new
ProxyNoExactSizeSpliterator
.
OfInt
(
sp
,
proxyEstimateSize
);
IntStream
s
=
StreamSupport
.
int
ParallelStream
(
psp
);
IntStream
s
=
StreamSupport
.
int
Stream
(
psp
,
true
);
terminalOp
.
accept
(
s
);
Assert
.
assertTrue
(
psp
.
splits
>
0
,
String
.
format
(
"Number of splits should be greater that zero when proxyEstimateSize is %s"
,
...
...
@@ -386,14 +386,14 @@ public class StreamSpliteratorTest extends OpTestCase {
withData
(
data
).
stream
(
in
->
{
IntStream
out
=
f
.
apply
(
in
);
return
StreamSupport
.
intStream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
));
return
StreamSupport
.
intStream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
)
,
false
);
}).
exercise
();
withData
(
data
).
stream
((
in
)
->
{
IntStream
out
=
f
.
apply
(
in
);
return
StreamSupport
.
int
ParallelStream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
)
);
return
StreamSupport
.
int
Stream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
),
true
);
}).
exercise
();
}
...
...
@@ -455,7 +455,7 @@ public class StreamSpliteratorTest extends OpTestCase {
// @@@ Need way to obtain the target size
Spliterator
.
OfLong
sp
=
intermediateOp
.
apply
(
LongStream
.
range
(
0
,
1000
)).
spliterator
();
ProxyNoExactSizeSpliterator
.
OfLong
psp
=
new
ProxyNoExactSizeSpliterator
.
OfLong
(
sp
,
proxyEstimateSize
);
LongStream
s
=
StreamSupport
.
long
ParallelStream
(
psp
);
LongStream
s
=
StreamSupport
.
long
Stream
(
psp
,
true
);
terminalOp
.
accept
(
s
);
Assert
.
assertTrue
(
psp
.
splits
>
0
,
String
.
format
(
"Number of splits should be greater that zero when proxyEstimateSize is %s"
,
...
...
@@ -479,14 +479,14 @@ public class StreamSpliteratorTest extends OpTestCase {
withData
(
data
).
stream
(
in
->
{
LongStream
out
=
f
.
apply
(
in
);
return
StreamSupport
.
longStream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
));
return
StreamSupport
.
longStream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
)
,
false
);
}).
exercise
();
withData
(
data
).
stream
((
in
)
->
{
LongStream
out
=
f
.
apply
(
in
);
return
StreamSupport
.
long
ParallelStream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
)
);
return
StreamSupport
.
long
Stream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
),
true
);
}).
exercise
();
}
...
...
@@ -548,7 +548,7 @@ public class StreamSpliteratorTest extends OpTestCase {
// @@@ Need way to obtain the target size
Spliterator
.
OfDouble
sp
=
intermediateOp
.
apply
(
IntStream
.
range
(
0
,
1000
).
asDoubleStream
()).
spliterator
();
ProxyNoExactSizeSpliterator
.
OfDouble
psp
=
new
ProxyNoExactSizeSpliterator
.
OfDouble
(
sp
,
proxyEstimateSize
);
DoubleStream
s
=
StreamSupport
.
double
ParallelStream
(
psp
);
DoubleStream
s
=
StreamSupport
.
double
Stream
(
psp
,
true
);
terminalOp
.
accept
(
s
);
Assert
.
assertTrue
(
psp
.
splits
>
0
,
String
.
format
(
"Number of splits should be greater that zero when proxyEstimateSize is %s"
,
...
...
@@ -572,14 +572,14 @@ public class StreamSpliteratorTest extends OpTestCase {
withData
(
data
).
stream
(
in
->
{
DoubleStream
out
=
f
.
apply
(
in
);
return
StreamSupport
.
doubleStream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
));
return
StreamSupport
.
doubleStream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
)
,
false
);
}).
exercise
();
withData
(
data
).
stream
((
in
)
->
{
DoubleStream
out
=
f
.
apply
(
in
);
return
StreamSupport
.
double
ParallelStream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
)
);
return
StreamSupport
.
double
Stream
(()
->
out
.
spliterator
(),
OpTestCase
.
getStreamFlags
(
out
),
true
);
}).
exercise
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录