Refactor ProcessDetails and PreemptivePriorityScheduling #5448
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
clang-format -i --style=file path/to/your/file.java
Changes
Removed internal Process class from PreemptivePriorityScheduling
Updated PreemptivePriorityScheduling to use ProcessDetails from com.thealgorithms.devutils.entities
Modified PreemptivePrioritySchedulingTest to work with ProcessDetails
Updated ProcessDetails to include a priority field and relevant constructor
Motivation
This change brings PreemptivePriorityScheduling in line with other scheduling algorithms in the project (FCFSScheduling, RRScheduling, SJFScheduling, SRTFScheduling) which all use the common ProcessDetails class. This improves consistency across the codebase and makes it easier to maintain and extend the scheduling algorithms.
Implementation Details
The Process class previously defined within PreemptivePriorityScheduling has been removed.
PreemptivePriorityScheduling now uses ProcessDetails for all process-related operations.
The priority field has been added to ProcessDetails along with getter and setter methods.
A new constructor has been added to ProcessDetails to include the priority when creating a new process.
The scheduling logic in PreemptivePriorityScheduling has been updated to work with ProcessDetails objects.
Test cases in PreemptivePrioritySchedulingTest have been updated to use ProcessDetails.