6. TreeMap详解
简介
TreeMap平时没怎么用过,简单研究一下
主要结构
private final Comparator<? super K> comparator; //比较器,默认是自然比较,自己可以通过构造函数传入,compareTo决定了key不能为null
static final class Entry<K,V> implements Map.Entry<K,V> {
K key;
V value;
Entry<K,V> left;
Entry<K,V> right;
Entry<K,V> parent;
boolean color = BLACK;
}
总体看了一下之后,发现就是个红黑树,通过Comparator实现有序,线程不安全


浙公网安备 33010602011771号