接上一次Java Map原理备忘(二)。
TreeMap is a map implementation that keeps its entries sorted according to the natural ordering of its keys or better still using a comparator if provided by the user at construction time.
TreeMap是一个map实现,根据key的自然顺序对其条目进行排序,也可以在new TreeMap传入一个comparator。
By default, TreeMap sorts all its entries according to their natural ordering. For an integer, this would mean ascending order and for strings, alphabetical order.
默认TreeMap根据key的自然顺序对其条目进行排序,对于integer类型表示大小升序,对于字符串类型表示按字母顺序升序。
TreeMap, unlike a hash map and linked hash map, does not employ the hashing principle anywhere since it does not use an array to store its entries.
TreeMap与HashMap和LinkedHashMap不同,TreeMap在任何地方都不使用散列原则,因为它不使用数组来存储其条目。
TreeMap implements NavigableMap interface and bases it’s internal working on the principles of red-black trees。
TreeMap实现了NavigableMap接口,其内部基于红黑树的原理。
public class TreeMap<K,V>
extends AbstractMap<K,V>
implements NavigableMap<K,V>, Cloneable, java.io.Serializable
public interface NavigableMap<K,V> extends SortedMap<K,V>
网友评论