阅读this Oracle教程,偶然发现了List范围查看操作与SortedSet界面提供的操作之间的区别。
我对这个有点感兴趣:
the range-viewoperationsaresomewhatanalogoustothoseprovidedby
the List interface,butthereisonebigdifference.rangeviewsofa
sortedsetremainvalidevenifthebackingsortedsetismodified
directly.thisisfeasiblebecausetheendpointsofarangeviewofa
sortedsetareabsolutepointsintheelementspaceratherthan
specificelementsinthebackingcollection,as is the case for lists。
有人能用其他语言说明大胆的部分吗?
提前表示感谢。
解决方法:
假设有一个包含列表和整数11、13、15和17的集合。
可以编写set.subset (12,15 )构建视图,并将12插入到原始集中。 这样,视图中将显示12。
名单无法做到这一点。 即使可以构建视图,也会在结构上更改原始列表(如插入元素)时禁用视图。
标签: java、sortedset、list
资料来源: https://codeday.me/bug/2019 05 29/1178879.html