SWEEP: Upgraded to the navigable APIs on SortedSet<T> and SortedDictionary<TKey, TValue> - #1268
Merged
Merged
Conversation
…sEnum: Use GetViewAfter() to match the upstream code.
…dSet<T>.TryGetLast() rather than Max, since the latter is obsolete. Fixed implementation to throw InvalidOperationException in the same case that Java would throw a NoSuchElementException (when the collection is empty).
…calls and replaced them with navigable collection APIs, which will reduce allocations.
…e obsolete SortedSet<T>.Max property to calls to RemoveLast() and TryGetLast().
… obsolete SortedSet<T> properties Min and Max with RemoveFirst() and RemoveLast()
…all to obsolete SortedSet<T>.Min property with TryGetFirst().
…perties Min and Max with RemoveFirst(), RemoveLast() and TryGetLast()
…et<T>.TryGetPredecessor() overload with the new overload.
…l to obsolete SortedSet<T>.GetViewBetween() method and replaced with GetView().
… implementation to use GetViewAfter() and TryGetLast() of SortedDictionary<TKey, TValue> rather than resorting to LINQ calls.
…ending the use of LINQ for this specific case rather than using GetViewBefore().
paulirwin
approved these changes
Apr 20, 2026
paulirwin
left a comment
Contributor
There was a problem hiding this comment.
Approved with minor comments added.
Added discard as per PR feedback Co-authored-by: Paul Irwin <paulirwin@gmail.com>
Added discard as per PR feedback Co-authored-by: Paul Irwin <paulirwin@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the changes (Less than 80 chars)
Upgraded to the navigable APIs on
SortedSet<T>andSortedDictionary<TKey, TValue>Description
This upgrades several classes to use the navigable APIs of
SortedSet<T>andSortedDictionary<TKey, TValue>. These APIs are available in the JDK but are missing in the BCL. J2N added support in NightOwl888/J2N#178.Several lines of LINQ code were removed and replaced with calls that don't produce so many allocations. Some behavior that throws exceptions in the JDK was also patched to throw under the same conditions in .NET, but replaces the
NoSuchElementExceptionin Java withInvalidOperationException.