- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我今天阅读了有关拆分器的内容,并使用 Spliterators.spliteratorUnknownSize(iterator(), Spliterator.NONNULL)
实现了一个。根据 spliteratorUnknownSize()
的文档
The [resulting] spliterator is not late-binding
作为拆分器的新手,我想知道为什么会这样。如果我确保 iterator()
是后期绑定(bind)的,那么生成的拆分器也应该是,不是吗? spliteratorUnknownSize()
只是创建一个尚未绑定(bind)到元素源的 IteratorSpliterator
。
即,我很想了解为什么生成的拆分器不是后期绑定(bind)的。谢谢。
最佳答案
根据javadocs :
"A
Spliterator
that does not reportIMMUTABLE
orCONCURRENT
is expected to have a documented policy concerning: when theSpliterator
binds to the element source; and detection of structural interference of the element source detected after binding. A late-bindingSpliterator
binds to the source of elements at the point of first traversal, first split, or first query for estimated size, rather than at the time theSpliterator
is created. ASpliterator
that is not late-binding binds to the source of elements at the point of construction or first invocation of any method. Modifications made to the source prior to binding are reflected when theSpliterator
is traversed. After binding aSpliterator
should, on a best-effort basis, throwConcurrentModificationException
if structural interference is detected. ..."
因此,如果您仔分割析,后期绑定(bind) 与非后期绑定(bind) 的真正区别在于何时开始检测结构干扰。
Spliterator
包装任意 迭代器不能保证检测到结构干扰。这取决于 Iterator
是如何实现的。即使对于检测(或减轻)结构干扰的 Iterators
,Spliterator
也无法保证检测何时开始;即当“绑定(bind)”发生时。
简而言之,它不能保证真正的后期绑定(bind)语义。
If I ensure
iterator()
to be late-binding, the resultingSpliterator
should also be, no?
javadocs 不保证这一点。
在实践中:它可能应该是,尽管它取决于 Spliterators
的实现。但是在 javadoc 中做出这样的声明可能会以有害的方式限制 future 版本的 Spliterators
类及其嵌套类的实现。
您可能不同意我的分析。然而,javadocs 的作者已经明确而有意地声明这些 Spliterator
不是后期绑定(bind)的。如果您认为他们对此有误,请针对 javadoc 提出错误报告。
关于java - 为什么 Spliterators.spliteratorUnknownSize() 不是后期绑定(bind)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54138679/
总结 我需要在 Camel 服务器 in-modify-out 过程中构建一组统计数据,并将这些统计数据作为一个对象(单个 json 日志行)发出。这些统计数据需要包括: input file met
某个元素使用以下 CSS 功能产生了惊人的结果: 盒子阴影;边界半径;边框和背景上的 RGBA 颜色。 问题是前两个需要延迟 Firefox/Chrome/Safari 浏览器,第二个不兼容 IE8
在我的 Rails 应用程序中有这段代码: window.onload = -> $("#mycontainer").typewriter() $("#div1").fadeIn("slow"
我想检查我的 api 是否工作正常。我有一个只有 post 请求而没有 GET 的 api。 教程在这里:https://learn.microsoft.com/en-us/azure/applica
我想检查我的 api 是否工作正常。我有一个只有 post 请求而没有 GET 的 api。 教程在这里:https://learn.microsoft.com/en-us/azure/applica
我是一名优秀的程序员,十分优秀!