java - TreeMap: NavigableMap<K,V> subMap(),它是否创建了新的 map 对象?

标签 java treemap

public NavigableMap<K,V> subMap(K fromKey,
                       boolean fromInclusive,
                       K toKey,
                       boolean toInclusive)

Description copied from interface: NavigableMap Returns a view of the portion of this map whose keys range from fromKey to toKey. If fromKey and toKey are equal, the returned map is empty unless fromInclusive and toInclusive are both true. The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

这个函数是否创建新的 map 对象?返回对象中存储了什么?

最佳答案

Does this function create new map object?

是的,但是这个 Map 对象没有 map 中保存键和值的节点的新副本。如果您更改底层 map ,它可以更改此 map 。

关于java - TreeMap: NavigableMap<K,V> subMap(),它是否创建了新的 map 对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38486025/

相关文章:

java - Java中如何强制关闭窗口?

java - 将字符串文本文件转换为对象数组

java - 树状图放置似乎正在删除条目

java - 添加键值后如何保持树状图排序

r - 在ggplot2中使用圆形包装可视化分层数据?

java - 使用 TreeMap 时出现 ClassCastException

java - weblogic 上的 Seam + hibernate + jsf

java - VisualVM OQL : how to search for primitive float values rather than actual Float instances?

java/jackson - 链式@JsonValue 注释和反序列化

java - 更改另一个 JComboBox 后填充 JComboBox