Java: why is TreeMap called "Tree"?

I cannot understand why TreeMap is called TreeMap but not SortedMap. As I understand it, TreeMap is a map that automatically sorts its elements. The tree in computer science is like a graph. So why?

+4
source share
3 answers

Since TreeMap is implemented by Red-Black Tree

+5
source

I cannot understand why TreeMap is called TreeMap but not SortedMap.

TreeMaprepresents an implementation of an interface SortedMap. or implemented . SortedMapTreeMap

As I understand it, TreeMap is a map that automatically sorts its elements.

, TreeMap , .

+3

. , TreeMap - . Javadocs:

SortedMap Red-Black. , , (. ), , , , .

, , ( , ) , - . ( , ). , Map , , compareTo ( compare), , , , . , ; .

+3

Source: https://habr.com/ru/post/1612526/


All Articles