Skip to content

Commit

Permalink
Changed the comments to make it more clear what was happening here.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brideau committed Jul 20, 2013
1 parent e27d1b1 commit 92b3e82
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Chapter 3 - Offices and Restrooms/example3-4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
# iterate over a period
DURATION.times do |t|
data[population_size] << restroom.queue.size # we want the queue size
queue = restroom.queue.clone # clone the queue so that we don't mess up the live one
restroom.queue.clear # clear the queue
queue = restroom.queue.clone # create a temporary queue so that we can sort people between the facilities and the restroom queue for this "tick"
restroom.queue.clear # clear the queue to prepare for the sorting

# let everyone from the queue enter the restroom first
# take each person from the temporary queue and try adding them to a facility
until queue.empty?
restroom.enter queue.shift # de-queue the first person in line and move him to the restroom
restroom.enter queue.shift # de-queue the person at the front of the line, place in an unoccupied facility or, if none, back to the restroom queue
end


Expand Down

0 comments on commit 92b3e82

Please sign in to comment.