Repository navigation
Conversation
A KeySorter sorts on a non-negative int key instead of a Comparator, which allows linear-time sorting (radix sort). SorterConfiguration gets usesKeySorter() and getKeySorter() as defaults, so existing configurations keep compiling. Bumps the version to 1.3.0.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the key-based radix-sort API extension.
No open issues 🎉
What changed in this PR
Extends the sorting service API to support the assignment’s fifth sorter, LSD radix sort, through a key-based sorting contract rather than an implementation.
Changes:
- Adds
KeySorter<T>with stable sorting, non-negative integer keys, and a same-queue return contract. - Adds
SortKind.RADIXand backward-compatible default methods for key-sorter configurations. - Bumps the package version to
1.3.0for the dependent solution release.
| File | Description |
|---|---|
src/main/java/sortingservice/SortKind.java |
Adds the RADIX enum value. |
src/main/java/sortingservice/SorterConfiguration.java |
Adds default usesKeySorter() and getKeySorter() methods. |
src/main/java/sortingservice/KeySorter.java |
Defines the key-based sorting interface and its contract. |
pom.xml |
Updates the package version to 1.3.0. |
Review effort: Balanced
…ations getQueue() returns null for a configuration with a priority queue. getSorter() returns a pass-through sorter for a priority queue configuration, and null for one with a key sorter.
This branch has not been deployed
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
Adds what the sorting assignment needs for a fifth, linear-time sorter (LSD radix sort):
KeySorter<T>:Queue<T> sort(Queue<T> queue, ToIntFunction<T> key). It sorts on a non-negativeintkey instead of aComparator, is stable, and throwsIllegalArgumentExceptionfor a negative key.SortKind.RADIX.SorterConfiguration.usesKeySorter()andgetKeySorter()as default methods (false/null), so existing configurations keep compiling.The version goes to 1.3.0.
After merging
Create release
v1.3.0, so the deploy workflow publishes the package and the javadoc. The solution PR ofalda_sorting_solutiondepends on this version.Testing
mvn installandmvn compile javadoc:javadocpass with no javadoc warnings. The solution's teacher tests (140) pass against the locally installed 1.3.0.Fixes from the consistency review
getQueue()andgetSorter()now says what they return for special configurations:getQueue()returnsnullfor a priority queue configuration;getSorter()returns a pass-through sorter for a priority queue configuration andnullfor a key sorter.