Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
c93a4cd9
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看板
提交
c93a4cd9
编写于
7月 12, 2013
作者:
H
henryjen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8015320: Pull spliterator() up from Collection to Iterable
Reviewed-by: psandoz, mduigou Contributed-by: brian.goetz@oracle.com
上级
29367018
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
48 addition
and
5 deletion
+48
-5
src/share/classes/java/lang/Iterable.java
src/share/classes/java/lang/Iterable.java
+27
-0
src/share/classes/java/util/Collection.java
src/share/classes/java/util/Collection.java
+1
-0
src/share/classes/java/util/ConcurrentModificationException.java
...re/classes/java/util/ConcurrentModificationException.java
+1
-0
test/java/util/Spliterator/SpliteratorCollisions.java
test/java/util/Spliterator/SpliteratorCollisions.java
+4
-5
test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java
...il/Spliterator/SpliteratorTraversingAndSplittingTest.java
+15
-0
未找到文件。
src/share/classes/java/lang/Iterable.java
浏览文件 @
c93a4cd9
...
...
@@ -26,6 +26,8 @@ package java.lang;
import
java.util.Iterator
;
import
java.util.Objects
;
import
java.util.Spliterator
;
import
java.util.Spliterators
;
import
java.util.function.Consumer
;
/**
...
...
@@ -72,5 +74,30 @@ public interface Iterable<T> {
action
.
accept
(
t
);
}
}
/**
* Creates a {@link Spliterator} over the elements described by this
* {@code Iterable}.
*
* @implSpec
* The default implementation creates an
* <em><a href="Spliterator.html#binding">early-binding</a></em>
* spliterator from the iterable's {@code Iterator}. The spliterator
* inherits the <em>fail-fast</em> properties of the iterable's iterator.
*
* @implNote
* The default implementation should usually be overridden. The
* spliterator returned by the default implementation has poor splitting
* capabilities, is unsized, and does not report any spliterator
* characteristics. Implementing classes can nearly always provide a
* better implementation.
*
* @return a {@code Spliterator} over the elements described by this
* {@code Iterable}.
* @since 1.8
*/
default
Spliterator
<
T
>
spliterator
()
{
return
Spliterators
.
spliteratorUnknownSize
(
iterator
(),
0
);
}
}
src/share/classes/java/util/Collection.java
浏览文件 @
c93a4cd9
...
...
@@ -537,6 +537,7 @@ public interface Collection<E> extends Iterable<E> {
* @return a {@code Spliterator} over the elements in this collection
* @since 1.8
*/
@Override
default
Spliterator
<
E
>
spliterator
()
{
return
Spliterators
.
spliterator
(
this
,
0
);
}
...
...
src/share/classes/java/util/ConcurrentModificationException.java
浏览文件 @
c93a4cd9
...
...
@@ -57,6 +57,7 @@ package java.util;
* @author Josh Bloch
* @see Collection
* @see Iterator
* @see Spliterator
* @see ListIterator
* @see Vector
* @see LinkedList
...
...
test/java/util/Spliterator/SpliteratorCollisions.java
浏览文件 @
c93a4cd9
...
...
@@ -48,7 +48,6 @@ import java.util.Spliterator;
import
java.util.TreeSet
;
import
java.util.function.Consumer
;
import
java.util.function.Function
;
import
java.util.function.LongConsumer
;
import
java.util.function.Supplier
;
import
java.util.function.UnaryOperator
;
...
...
@@ -677,11 +676,11 @@ public class SpliteratorCollisions {
private
static
<
T
>
Map
<
T
,
HashableInteger
>
toBoxedMultiset
(
Iterable
<
T
>
c
)
{
Map
<
T
,
HashableInteger
>
result
=
new
HashMap
<>();
c
.
forEach
(
(
Consumer
)
e
->
{
if
(
result
.
containsKey
(
(
T
)
e
))
{
result
.
put
(
(
T
)
e
,
new
HashableInteger
(((
HashableInteger
)
result
.
get
(
e
)
).
value
+
1
,
10
));
c
.
forEach
(
e
->
{
if
(
result
.
containsKey
(
e
))
{
result
.
put
(
e
,
new
HashableInteger
(
result
.
get
(
e
).
value
+
1
,
10
));
}
else
{
result
.
put
(
(
T
)
e
,
new
HashableInteger
(
1
,
10
));
result
.
put
(
e
,
new
HashableInteger
(
1
,
10
));
}
});
return
result
;
...
...
test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java
浏览文件 @
c93a4cd9
...
...
@@ -321,6 +321,21 @@ public class SpliteratorTraversingAndSplittingTest {
db
.
addCollection
(
c
->
new
AbstractSortedSetImpl
(
c
));
class
IterableWrapper
implements
Iterable
<
Integer
>
{
final
Iterable
<
Integer
>
it
;
IterableWrapper
(
Iterable
<
Integer
>
it
)
{
this
.
it
=
it
;
}
@Override
public
Iterator
<
Integer
>
iterator
()
{
return
it
.
iterator
();
}
}
db
.
add
(
"new Iterable.spliterator()"
,
()
->
new
IterableWrapper
(
exp
).
spliterator
());
//
db
.
add
(
"Arrays.asList().spliterator()"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录