加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – Spliterator – size vs subsized flags

发布时间:2020-12-14 05:40:20 所属栏目:Java 来源:网络整理
导读:https://docs.oracle.com/javase/8/docs/api/java/util/Spliterator.html SIZED Characteristic value signifying that the value returned from estimateSize() prior to traversal or splitting represents a finite size that,in the absence of structur
https://docs.oracle.com/javase/8/docs/api/java/util/Spliterator.html

SIZED Characteristic value signifying that the value returned from
estimateSize() prior to traversal or splitting represents a finite
size that,in the absence of structural source modification,
represents an exact count of the number of elements that would be
encountered by a complete traversal.

SUBSIZED Characteristic value signifying that all Spliterators
resulting from trySplit() will be both SIZED and SUBSIZED.

>是否存在SIZED标志打开但SUBSIZED标志关闭的情况?
>是否存在SUBSIZED标志打开但SIZED标志关闭的情况?

解决方法

Spliterator的典型示例是SIZED但不是SUBSIZED,是从HashMap创建的Spliterator.它将在其内部条目数组中保持一个范围,其中一些数组条目为空,因为容量高于实际大小.要跳过的空条目的确切分布取决于包含的键的哈希码.

因此,Spliterator最初确实知道它的(总)大小,但是当分割范围时,它不知道每个范围中有多少元素. HashMap具有的元素越多,大致平衡分割的可能性就越高,因此这种策略是合理的,但确切的子集是未知的,并且需要对数组进行迭代才能找到.

报告没有SIZED的SUBSIZED特征是没有意义的,据我所知,甚至没有效果.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读