Java – how do I get the last 25 elements of sortedset?
                                        
                    •
                    Java                                    
                In Java, I have a sortedset, which may have 100000 elements I want to get the last 25 elements efficiently and gracefully I'm a little confused
To get the 25th element, I will iterate and stop after 25 elements But I don't know how to iterate in reverse order Any ideas?
SortedSet<Integer> summaries = getSortedSet(); // what goes here :-(
Solution
You need a navigableset Otherwise, you will have to perform inefficiently, traverse the entire sortedset and collect the elements into a queue, and you will keep 25 elements
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        