• Java TreeMap类简介说明


    转自:

    Java TreeMap类简介说明

    下文讲述TreeMap类的功能简介说明,如下所示:

    TreeMap继承了NavigableMap
      而NavigableMap继承自SortedMap
      为SortedMap添加了搜索选项 
    

    TreeMap构造函数

    //无参构造函数
    TreeMap()
    // 创建的TreeMap包含Map
    TreeMap(Map copyFrom)
    //设置Tree的比较器
    TreeMap(Comparator comparator)
    //创建的TreeSet包含copyFrom
    TreeMap(SortedMap copyFrom)
    

    TreeMap属性

    //比较器 由于TreeMap是有序的,可以通过定义外部比较器,为Treemap设置自定义比较规则 
    private final Comparator comparator;
    //TreeMap红-黑节点,为TreeMap的内部类
    private transient Entry root = null;
    //容器大小
    private transient int size = 0;
    //TreeMap修改次数
    private transient int modCount = 0;
    //红黑树的节点颜色--红色
    private static final boolean RED = false;
    //红黑树的节点颜色--黑色
    private static final boolean BLACK = true;
    

    TreeMap方法

    Entry                ceilingEntry(K key)
    K                          ceilingKey(K key)
    void                       clear()
    Object                     clone()
    Comparator      comparator()
    boolean                    containsKey(Object key)
    NavigableSet            descendingKeySet()
    NavigableMap         descendingMap()
    Set>           entrySet()
    Entry                firstEntry()
    K                          firstKey()
    Entry                floorEntry(K key)
    K                          floorKey(K key)
    V                          get(Object key)
    NavigableMap         headMap(K to, boolean inclusive)
    SortedMap            headMap(K toExclusive)
    Entry                higherEntry(K key)
    K                          higherKey(K key)
    boolean                    isEmpty()
    Set                     keySet()
    Entry                lastEntry()
    K                          lastKey()
    Entry                lowerEntry(K key)
    K                          lowerKey(K key)
    NavigableSet            navigableKeySet()
    Entry                pollFirstEntry()
    Entry                pollLastEntry()
    V                          put(K key, V value)
    V                          remove(Object key)
    int                        size()
    SortedMap            subMap(K fromInclusive, K toExclusive)
    NavigableMap         subMap(K from, boolean fromInclusive, K to, boolean toInclusive)
    NavigableMap         tailMap(K from, boolean inclusive)
    SortedMap            tailMap(K fromInclusive)
  • 相关阅读:
    SpringBoot 整合 Neo4j
    Vue路由
    【教3妹学mysql】一条慢sql如何排查优化
    Python 中的滚动赫斯特指数-可视化市场节奏
    【毕业设计源码】基于小程序蔬菜/零食商城系统
    【计算机网络笔记】什么是网络协议?
    Linux:kubernetes(k8s)有状态的服务部署(14)
    ElasticSearch的简单了解和使用
    浮点数机制学习
    OSError: [WinError 123] 文件名、目录名或卷标语法不正确
  • 原文地址:https://blog.csdn.net/qq_25073223/article/details/126340214