bestJavaer icon indicating copy to clipboard operation
bestJavaer copied to clipboard

疑问?TreeMap底层不就是一颗红黑树吗?怎么变成数组加红黑树了?

Open silky1313 opened this issue 1 year ago • 0 comments

public class TreeMap<K,V>
    extends AbstractMap<K,V>
    implements NavigableMap<K,V>, Cloneable, java.io.Serializable
{
    /**
     * The comparator used to maintain order in this tree map, or
     * null if it uses the natural ordering of its keys.
     *
     * @serial
     */
    @SuppressWarnings("serial") // Conditionally serializable
    private final Comparator<? super K> comparator;

    private transient Entry<K,V> root;

    /**
     * The number of entries in the tree
     */
    private transient int size = 0;

    /**
     * The number of structural modifications to the tree.
     */
    private transient int modCount = 0;
}

silky1313 avatar Apr 03 '24 06:04 silky1313