Skip to content

Commit 6631350

Browse files
committed
fix formatting
1 parent 7e43774 commit 6631350

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

src/main/java/com/thealgorithms/scheduling/PreemptivePriorityScheduling.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.thealgorithms.scheduling;
22

33
import com.thealgorithms.devutils.entities.ProcessDetails;
4-
54
import java.util.ArrayList;
65
import java.util.Comparator;
76
import java.util.List;
@@ -22,10 +21,7 @@ public PreemptivePriorityScheduling(List<ProcessDetails> processes) {
2221
}
2322

2423
public void scheduleProcesses() {
25-
PriorityQueue<ProcessDetails> readyQueue = new PriorityQueue<>(
26-
Comparator.comparingInt(ProcessDetails::getPriority).reversed()
27-
.thenComparingInt(ProcessDetails::getArrivalTime)
28-
);
24+
PriorityQueue<ProcessDetails> readyQueue = new PriorityQueue<>(Comparator.comparingInt(ProcessDetails::getPriority).reversed().thenComparingInt(ProcessDetails::getArrivalTime));
2925

3026
int currentTime = 0;
3127
int processIndex = 0;

src/test/java/com/thealgorithms/scheduling/PreemptivePrioritySchedulingTest.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package com.thealgorithms.scheduling;
22

3-
import com.thealgorithms.devutils.entities.ProcessDetails;
4-
import org.junit.jupiter.api.Test;
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
54

5+
import com.thealgorithms.devutils.entities.ProcessDetails;
66
import java.util.ArrayList;
77
import java.util.List;
8-
9-
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
import org.junit.jupiter.api.Test;
109

1110
/**
1211
* Test Cases of Preemptive Priority Scheduling Algorithm
@@ -26,9 +25,7 @@ void testPreemptivePriorityScheduling() {
2625
PreemptivePriorityScheduling scheduler = new PreemptivePriorityScheduling(processes);
2726
scheduler.scheduleProcesses();
2827

29-
List<String> expectedSchedule = List.of(
30-
"P1", "P2", "P3", "P3", "P4", "P2", "P2", "P2", "P1", "P1", "P1", "P1"
31-
);
28+
List<String> expectedSchedule = List.of("P1", "P2", "P3", "P3", "P4", "P2", "P2", "P2", "P1", "P1", "P1", "P1");
3229

3330
assertEquals(expectedSchedule, scheduler.ganttChart);
3431
}
@@ -43,9 +40,7 @@ void testPreemptivePrioritySchedulingWithIdleTime() {
4340
PreemptivePriorityScheduling scheduler = new PreemptivePriorityScheduling(processes);
4441
scheduler.scheduleProcesses();
4542

46-
List<String> expectedSchedule = List.of(
47-
"Idle", "Idle", "P1", "P1", "P1", "P2", "P2", "P3", "P2", "P1", "P1"
48-
);
43+
List<String> expectedSchedule = List.of("Idle", "Idle", "P1", "P1", "P1", "P2", "P2", "P3", "P2", "P1", "P1");
4944

5045
assertEquals(expectedSchedule, scheduler.ganttChart);
5146
}

0 commit comments

Comments
 (0)