eclipse-collections
eclipse-collections copied to clipboard
Fix SortedSetIterable getFirst/getLast to return null on empty sets.
The sorted set implementations (TreeSortedSet, SortedSetAdapter, AbstractImmutableSortedSet) previously delegated getFirst() and getLast() to java.util.SortedSet's first() and last() methods, which throw NoSuchElementException when the set is empty. This violated the RichIterable/OrderedIterable contract which specifies that getFirst() and getLast() should return null for empty collections.
Changed to check isEmpty() before calling first()/last(), returning null for empty sets. Updated SortedSetIterableTestCase to remove the assertThrows tests that verified the incorrect exception behavior.