.reverseIterator
over .reverse.iterator
SC-P1010The reverse method reverses the ordering of the collection. Chaining it with iterator
returns the iterator for this reversed order.
However, consider using the provided suitable and efficient alternative .reverseIterator
as it is defined for this very specific purpose.
This is more suitable and efficient as:
There is no reversing involved, and,
No resources are allocated for the intermediate buffer to hold the reversed order as the operation itself is made redundant.
nums.reverse.iterator
nums.reverseIterator