Skip to content

feat: add KeySorter and SortKind.RADIX - #5

Open
Bonajo wants to merge 2 commits into
mainfrom
feature/radix-sorter
Open

Bonajo wants to merge 2 commits into
mainfrom
feature/radix-sorter

Conversation

@Bonajo

@Bonajo Bonajo commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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-negative int key instead of a Comparator, is stable, and throws IllegalArgumentException for a negative key.
  • SortKind.RADIX.
  • SorterConfiguration.usesKeySorter() and getKeySorter() 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 of alda_sorting_solution depends on this version.

Testing

mvn install and mvn compile javadoc:javadoc pass with no javadoc warnings. The solution's teacher tests (140) pass against the locally installed 1.3.0.

Fixes from the consistency review

  • The javadoc of getQueue() and getSorter() now says what they return for special configurations: getQueue() returns null for a priority queue configuration; getSorter() returns a pass-through sorter for a priority queue configuration and null for a key sorter.

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.
Copilot AI balanced review requested due to automatic review settings October 28, 2026 12:29

Copilot AI 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.

🟢 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.RADIX and backward-compatible default methods for key-sorter configurations.
  • Bumps the package version to 1.3.0 for 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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants