nus-cs2030 / 2122-s2

CS2030 repository and wiki for AY 2021/2022 Sem 2
MIT License
0 stars 0 forks source link

Level 5 Customer service time #290

Open yongchein-o opened 2 years ago

yongchein-o commented 2 years ago

The question states This is followed by the arrival times of the customers. Lastly, a number of service times (could be more than necessary) are provided.

Why is there more than necessary?

I also don't quite get what this is trying to say

What is interesting in the above is that the second customer with the arrival time of 0.6, is the first one to be served with a new input of 1.0. Also note that if you invoke the same jshell test again, another input is read and returned, rather than returning the value that was last read.

jshell> list.get(1).second().get() // same test
2.0
$.. ==> 2.0

Anyone able to explain? thanks in advance

wzs02 commented 2 years ago

Hey Yong Chein, I think they're trying to say that, for example:

Hope this clears things up!

jamietan123 commented 2 years ago

^Yup, so one possible way of doing it would be to only call the get() of the Lazy class when the customer is being served

yongchein-o commented 2 years ago

Alright thanks!

kh1js commented 2 years ago

Hi , can I check the difference between using Lazy to cache the service time and calling get() of the Lazy class when the customer is being served?

wjahoward commented 2 years ago

Hi @kh1js, I think is when the current customer is being served, by calling get(), the service time will be retrieved directly and pass it over to that customer. Caching service time is essentially storing that particular service time to some "data". When that service time is needed, can just retrieve it from that "data".

kh1js commented 2 years ago

Thank you for your help @wjahoward! I will try to store the service time in lazy.