java TreeMap类

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java TreeMap类相关的知识,希望对你有一定的参考价值。

The TreeMap class implements the Map interface by using a tree. 
A TreeMap provides an efficient means of storing key/value pairs in sorted order, and allows rapid retrieval.

// initialization
TreeMap<Integer, List<Integer>> tree = new TreeMap<>();

tree.add()
tree.clear()
tree.containsKey()
tree.keySet()
tree.put(key, value)
tree.pollFirstEntry()
Removes and returns a key-value mapping associated with the least key in this map, or null if the map is empty.
tree.pollLastEntry()
Removes and returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.

以上是关于java TreeMap类的主要内容,如果未能解决你的问题,请参考以下文章

Java集合框架 Map接口实现类--TreeMap的使用 & TreeMap和TreeSet的关系

java TreeMap类

大数据Java基础DAY21——集合完结(Map接口,HashMap,Linked Hash Map,TreeMap,Collections类)

Java中将一个TreeMap添加到另一个TreeMap中怎么做?

MapTreeMap

java:容器/集合(Map(HashMap,TreeMap))