A NavigableSet implementation based on a TreeMap. The elements are ordered using their natural ordering, or by a Comparator provided at set creation time, depending on which constructor is used.This implementation provides guaranteed log(n) time cost for the basic operations (add, remove and contains).
1.概述
TreeSet是基于TreeMap实现的,也非常简单,同样的只是用key及其操作,然后把value置为dummy的object。
其具体的结构是:
利用TreeMap的特性,实现了set的有序性(通过红黑树实现)。
参考资料
TreeSet(Java Platform SE 8)