style: include OCP_OVERLY_CONCRETE_PARAMETER (#5833)

This commit is contained in:
Piotr Idzik
2024-10-14 22:46:28 +02:00
committed by GitHub
parent 3af4cfd7c8
commit 8886e0996a
28 changed files with 46 additions and 33 deletions

View File

@@ -183,7 +183,7 @@ public class BoruvkaAlgorithmTest {
* @param result list of edges in the Minimum Spanning Tree
* @return the total weight of the Minimum Spanning Tree
*/
int computeTotalWeight(final List<BoruvkaAlgorithm.Edge> result) {
int computeTotalWeight(final Iterable<BoruvkaAlgorithm.Edge> result) {
int totalWeight = 0;
for (final var edge : result) {
totalWeight += edge.weight;

View File

@@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.Test;
@@ -25,7 +26,7 @@ public class EdmondsBlossomAlgorithmTest {
* @param matching List of matched pairs returned by the algorithm.
* @return A sorted 2D array of matching pairs.
*/
private int[][] convertMatchingToArray(List<int[]> matching) {
private int[][] convertMatchingToArray(Collection<int[]> matching) {
// Convert the list of pairs into an array
int[][] result = matching.toArray(new int[0][]);

View File

@@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach;
@@ -44,7 +45,7 @@ class WordBoggleTest {
@ParameterizedTest
@MethodSource("provideSpecialCases")
void testBoggleBoardSpecialCases(char[][] specialBoard, String[] words, List<String> expectedWords, String testDescription) {
void testBoggleBoardSpecialCases(char[][] specialBoard, String[] words, Collection<String> expectedWords, String testDescription) {
List<String> result = WordBoggle.boggleBoard(specialBoard, words);
assertEquals(expectedWords.size(), result.size(), "Test failed for: " + testDescription);
assertTrue(expectedWords.containsAll(result), "Test failed for: " + testDescription);

View File

@@ -3,6 +3,7 @@ package com.thealgorithms.scheduling;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.thealgorithms.devutils.entities.ProcessDetails;
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
@@ -17,7 +18,7 @@ import org.junit.jupiter.params.provider.MethodSource;
class PreemptivePrioritySchedulingTest {
@ParameterizedTest
@MethodSource("provideProcessesAndExpectedSchedules")
void testPreemptivePriorityScheduling(List<ProcessDetails> processes, List<String> expectedSchedule) {
void testPreemptivePriorityScheduling(Collection<ProcessDetails> processes, List<String> expectedSchedule) {
PreemptivePriorityScheduling scheduler = new PreemptivePriorityScheduling(processes);
scheduler.scheduleProcesses();
assertEquals(expectedSchedule, scheduler.ganttChart);

View File

@@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -225,7 +226,7 @@ class QuickSelectTest {
return RANDOM.ints(n, ASCII_A, ASCII_Z).mapToObj(i -> (char) i).collect(Collectors.toList());
}
private static <T extends Comparable<T>> List<T> getSortedCopyOfList(List<T> list) {
private static <T extends Comparable<T>> List<T> getSortedCopyOfList(Collection<T> list) {
return list.stream().sorted().collect(Collectors.toList());
}
}