From 7987632b2bff194aea1528225f29a1fa2c890aba Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sat, 18 Mar 2023 17:49:15 +0200 Subject: [PATCH] reucrisisosnoigvnoi!!!11 <#<#3,,33,klsajdsaklj :D --- src/main.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 61ba135..5e746b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,13 +52,13 @@ pub struct Process { completed: bool, } impl Process { - pub fn proc(mut self, q: i32, current: i32) -> i32 { + pub fn proc(mut self, q: i32, current: i32) -> (Process, i32, i32) { self.remaining -= q; - if self.remaining == 0 { - self.completed = true; - self.completion_time = current + q; + if self.remaining > 0 { + (self, self.remaining - q, current + q) + } else { + (self, 0, current) } - current + q } pub fn calc_turn(self) -> i32 { self.completion_time - self.arrival @@ -70,8 +70,6 @@ impl Process { self.completion_time = current + self.remaining; self.completed = true; self.remaining = 0; - self.calc_turn(); - self.calc_wait(); (self, self.completion_time) } } @@ -111,7 +109,6 @@ pub fn sjf(mut procs: Vec, mut completed: Vec) -> Vec if procs.is_empty() { completed_procs } else { - } } }