Skip to content

Commit e21a21f

Browse files
committed
style: apply clang-format per CI
1 parent 1af30ca commit e21a21f

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

src/main/java/com/thealgorithms/sorts/BucketSort.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,19 @@ private <T extends Comparable<T>> T[] concatenateBuckets(Iterable<List<T>> bucke
9797
*
9898
*<p><b>Important limitations:</b>
9999
*<ul>
100-
* <li>This method uses {@code compareTo} as if it provided a numeric difference.
101-
* For numeric types, {@code compareTo} only reports order (−1, 0, 1), not the actual distance.
102-
* This often collapses distribution into one or two buckets.</li>
103-
* <li>For non-numeric {@code Comparable} types (for example {@code String}), bucket indices depend on lexicographic
104-
* code-point differences, which are not a proportional measure of spacing. Distribution is therefore arbitrary and uneven.</li>
105-
* <li>If {@code min.equals(max)}, the computed "range" is 0. Then {@code element.compareTo(min) / 0}
106-
* yields {@code NaN}, which Java coerces to 0 when cast to {@code int}.
107-
* Practically, all elements collapse into bucket 0 in this case.</li>
108-
* </ul>
109-
*
110-
* <p>Despite these limitations, the sort remains correct because each bucket is sorted internally and concatenated.
111-
* This method should be regarded as a simplified demonstration rather than a
112-
* general-purpose bucketing strategy for arbitrary {@code Comparable<T>} values.</p>
100+
* <li>This method uses {@code compareTo} as if it provided a numeric difference.
101+
* For numeric types, {@code compareTo} only reports order (−1, 0, 1), not the actual distance.
102+
* This often collapses distribution into one or two buckets.</li>
103+
* <li>For non-numeric {@code Comparable} types (for example {@code String}), bucket indices depend on lexicographic
104+
* code-point differences, which are not a proportional measure of spacing. Distribution is therefore arbitrary and uneven.</li>
105+
* <li>If {@code min.equals(max)}, the computed "range" is 0. Then {@code element.compareTo(min) / 0}
106+
* yields {@code NaN}, which Java coerces to 0 when cast to {@code int}.
107+
* Practically, all elements collapse into bucket 0 in this case.</li>
108+
* </ul>
109+
*
110+
* <p>Despite these limitations, the sort remains correct because each bucket is sorted internally and concatenated.
111+
* This method should be regarded as a simplified demonstration rather than a
112+
* general-purpose bucketing strategy for arbitrary {@code Comparable<T>} values.</p>
113113
*
114114
* @param element the element of the array
115115
* @param min the minimum value in the array

src/test/java/com/thealgorithms/sorts/BucketSortHashBehaviorTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@
99
public class BucketSortHashBehaviorTest {
1010

1111
private static <T extends Comparable<T>> int pseudoHash(final T element, final T min, final T max, final int numberOfBuckets) {
12-
//Reproduces the production hash() logic
12+
// Reproduces the production hash() logic
1313
double range = max.compareTo(min);
1414
double normalizedValue = element.compareTo(min) / range; // -1/0/1 divided by -1/0/1
1515
return (int) (normalizedValue * (numberOfBuckets - 1));
1616
}
1717

18-
@Test //Test case when all numbers are equal
18+
@Test // Test case when all numbers are equal
1919
void sort_stillCorrect_whenAllEqual() {
2020
Integer[] arr = {1, 1, 1, 1, 1};
2121
Integer[] expected = arr.clone();
2222

2323
new BucketSort().sort(arr);
2424
assertArrayEquals(expected, arr);
2525

26-
//Observe bucket mapping (all collapse to index 0)
26+
// Observe bucket mapping (all collapse to index 0)
2727
Integer min = 1, max = 1;
2828
int numberOfBuckets = Math.max(arr.length / 10, 1); // same as BUCKET_DIVISOR rule
2929
int idx = pseudoHash(1, min, max, numberOfBuckets);
30-
//idx will be 0 because NaN cast to int -> 0 in Java
30+
// idx will be 0 because NaN cast to int -> 0 in Java
3131
System.out.println("All-equal case -> bucket index: " + idx);
3232
}
3333

34-
@Test //Test case with non-equal integers
34+
@Test // Test case with non-equal integers
3535
void sort_stillCorrect_nonEqualIntegers() {
3636
Integer[] arr = {20, 40, 30, 10};
3737
Integer[] expected = {10, 20, 30, 40};
@@ -51,7 +51,7 @@ void sort_stillCorrect_nonEqualIntegers() {
5151
// Expect only two distinct buckets because compareTo gives -1/0/1
5252
}
5353

54-
@Test //Test case when the Array contains Strings
54+
@Test // Test case when the Array contains Strings
5555
void sort_stillCorrect_whenStrings() {
5656
String[] arr = {"apple", "banana", "carrot"};
5757
String[] expected = arr.clone();
@@ -70,4 +70,3 @@ void sort_stillCorrect_whenStrings() {
7070
// Buckets reflect only lexicographic order, not a numeric spacing
7171
}
7272
}
73-

0 commit comments

Comments
 (0)