Skip to content

SWEEP: Upgraded to the navigable APIs on SortedSet<T> and SortedDictionary<TKey, TValue> - #1268

Merged
NightOwl888 merged 13 commits into
apache:masterfrom
NightOwl888:feature/navigable-apis
Apr 23, 2026
Merged

SWEEP: Upgraded to the navigable APIs on SortedSet<T> and SortedDictionary<TKey, TValue>#1268
NightOwl888 merged 13 commits into
apache:masterfrom
NightOwl888:feature/navigable-apis

Conversation

@NightOwl888

Copy link
Copy Markdown
Contributor
  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a change, please open an issue to discuss the change or find an existing issue.

Summary of the changes (Less than 80 chars)

Upgraded to the navigable APIs on SortedSet<T> and SortedDictionary<TKey, TValue>

Description

This upgrades several classes to use the navigable APIs of SortedSet<T> and SortedDictionary<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 NoSuchElementException in Java with InvalidOperationException.

…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().
@NightOwl888
NightOwl888 requested a review from paulirwin April 20, 2026 19:23
@NightOwl888 NightOwl888 added the notes:improvement An enhancement to an existing feature label Apr 20, 2026

@paulirwin paulirwin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with minor comments added.

Comment thread src/Lucene.Net.Grouping/AbstractFirstPassGroupingCollector.cs Outdated
Comment thread src/Lucene.Net.Grouping/AbstractGroupFacetCollector.cs Outdated
NightOwl888 and others added 2 commits April 23, 2026 16:04
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>
@NightOwl888
NightOwl888 merged commit 29ddb24 into apache:master Apr 23, 2026
211 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:improvement An enhancement to an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants