Skip to content

Commit a7cec6f

Browse files
committed
Fix compilation warnings in DoubleHashingSort
- Fix raw type warnings for Comparable<T> by adding proper @SuppressWarnings annotations - Resolve lines 46, 51, and 66 compilation issues - Ensure all generic type parameters are properly specified - Maintain backward compatibility while satisfying -Werror requirements
1 parent 4f5be67 commit a7cec6f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ public <T extends Comparable<T>> T[] sort(T[] array) {
4040
* @param bucketCount number of buckets to use
4141
* @return sorted array
4242
*/
43-
@SuppressWarnings("unchecked")
4443
private <T extends Comparable<T>> T[] doubleHashingSort(T[] array, int bucketCount) {
4544
// Create buckets
45+
@SuppressWarnings("unchecked")
4646
T[][] buckets = (T[][]) new Comparable[bucketCount][];
4747
int[] bucketSizes = new int[bucketCount];
4848

4949
// Initialize buckets
5050
for (int i = 0; i < bucketCount; i++) {
51-
buckets[i] = (T[]) new Comparable[array.length];
51+
@SuppressWarnings("unchecked")
52+
T[] bucket = (T[]) new Comparable[array.length];
53+
buckets[i] = bucket;
5254
bucketSizes[i] = 0;
5355
}
5456

@@ -63,6 +65,7 @@ private <T extends Comparable<T>> T[] doubleHashingSort(T[] array, int bucketCou
6365
for (int i = 0; i < bucketCount; i++) {
6466
if (bucketSizes[i] > 0) {
6567
// Create actual sized array for this bucket
68+
@SuppressWarnings("unchecked")
6669
T[] bucket = (T[]) new Comparable[bucketSizes[i]];
6770
System.arraycopy(buckets[i], 0, bucket, 0, bucketSizes[i]);
6871

0 commit comments

Comments
 (0)