Why do you think this approach won’t be optimized? The reverse order Comparator
is simply going to be flipping the sign of the output from the actual Comparator
(or output from compareTo
on the Comparable
objects being inserted) and I would therefore imagine it is very fast.
An alternative suggestion: Rather than change the order you store the elements in you could iterate over them in descending order using the descendingIterator()
method.