简体   繁体   中英

Why there's no “descendingIterator ()” in SortedSet but it is in TreeSet?

The fact that it hasn't been added yet to the interface makes me think there must be some valid reason. While I think that you shouldn't be passing sets around merrily and, hence, the implementation class will rarely appear in the interface of a class in case reverse iteration is needed, IMO it would improve the SortedSet interface nonetheless.

descendingIterator was introduced in 1.6. SortedSet is an interface that was introduced in 1.2. You can't add methods to interface s (JDBC is "special").

In order to facilitate adding extra methods to a sorted set-like interface, 1.6 added the awkwardly named NavigableSet (and NavigableMap ). This is a replacement for SortedSet . Old implementations should be retrofitted with this new interface.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM