mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
style: include OCP_OVERLY_CONCRETE_PARAMETER (#5833)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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][]);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user