-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Create StalinSort.java #5720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create StalinSort.java #5720
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5720 +/- ##
============================================
- Coverage 62.93% 62.88% -0.06%
+ Complexity 4044 4043 -1
============================================
Files 567 568 +1
Lines 16030 16043 +13
Branches 3084 3086 +2
============================================
- Hits 10089 10088 -1
- Misses 5525 5538 +13
- Partials 416 417 +1 ☔ View full report in Codecov by Sentry. |
return trimArray(result, index); | ||
} | ||
|
||
private <T> T[] trimArray(T[] array, int length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just adds unnecessary overhead. We can remove this if we use ArrayList
.
List<T> result = new ArrayList<>();
result.add(array[0]);
for (int i = 1; i < array.length; i++) {
if (SortUtils.less(result.get(result.size() - 1), array[i])) {
result.add(array[i]);
}
}
|
||
@Override | ||
public <T extends Comparable<T>> T[] sort(T[] array) { | ||
if (array.length == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add null
check here to prevent null pointer exception.
Please add tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add JUnit tests
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution! |
Please reopen this pull request once you have made the required changes. If you need help, feel free to ask in our Discord server or ping one of the maintainers here. Thank you for your contribution! |
clang-format -i --style=file path/to/your/file.java