Are they AVL trees, re开发者_开发百科d-black trees, or something else?
Red-black trees as described in the first line of the javadoc.
- Tree Map
- Tree Set
From the java.util.TreeMap<K,V> documentation:
A Red-Black tree based
NavigableMapimplementation.
For questions like these, you should always first consult the documentation. The API shouldn't describe ALL of the inner-workings of a class, but elementary informations such as general data structures and algorithms used are usually documented.
Other Java Collections Framework trivias
These are all little trivias that are also clearly documented:
TreeSetis implemented with aTreeMapHashSetis implemented with aHashMapCollections.sortuses modified mergesortMap<K,V>is not aCollection<?>ArrayListdoesn't specify exact growth policy (unlike, say,Vector)
Related questions
- Why does
java.util.Arrays.sort(Object[])use 2 kinds of sorting algorithms? - Why does the Java Collections Framework offer two different ways to sort?
- Why doesn't Java Map extends Collection?
The first sentence of the TreeMap Javadoc states:
A Red-Black tree based
NavigableMapimplementation.
It is a red-black tree in the Oracle desktop Java implementation, but an AVL-tree in Android.
TreeSet is based on TreeMap. And they uses red-black tree, red-black tree is a kind of AVL.
加载中,请稍侯......
精彩评论