关于SortedSet界面,java教程
作者:互联网
阅读this Oracle教程我偶然发现了List的范围视图操作与SortedSet接口提供的操作之间差异的解释.
这有点兴趣:
The range-view operations are somewhat analogous to those provided by
the List interface, but there is one big difference. Range views of a
sorted set remain valid even if the backing sorted set is modified
directly. This is feasible because the endpoints of a range view of a
sorted set are absolute points in the element space rather than
specific elements in the backing collection, as is the case for lists.
是否有人能够用其他词语解释大胆的部分?
提前致谢.
解决方法:
假设你有一个列表和一个包含整数11,13,15和17的集合.
您可以编写set.subSet(12,15)来构造视图,然后将12插入到原始集中.如果这样做,12将出现在视图中.
列表无法实现这一点.即使您可以构造视图,在结构上修改原始列表的那一刻(例如插入元素),视图也会变得无效.
标签:java,sortedset,list 来源: https://codeday.me/bug/20190529/1178879.html