68 std::priority_queue<
event*,
69 std::vector<event *, std::allocator<event*> >,
81 nextEvent->processEvent ();
92 bool canSeat (
unsigned int numberOfPeople);
93 void order (
unsigned int numberOfScoops);
94 void leave (
unsigned int numberOfPeople);
104 :
event (
t), size (groupSize)
115 :
event (
t), size (groupSize)
127 :
event (
t), size (groupSize)
139 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf
142 std::random_shuffle (seq, seq +
sizeof seq /
sizeof *seq);
145 ((seq [0] << 11) | (seq [1] << 8) | (seq [2] << 4)) + seq [3];
162 for (
unsigned int i = 0;
i < size;
i++)
180 std::cout <<
"Time: " <<
time;
181 std::cout <<
" group of " << numberOfPeople <<
" customers arrives";
184 std::cout <<
" is seated\n";
189 std::cout <<
" no room, they leave\n";
198 std::cout <<
"Time: " <<
time <<
" serviced order for "
199 << numberOfScoops <<
'\n';
200 profit += 0.35 * numberOfScoops;
207 std::cout <<
"Time: " <<
time <<
" group of size "
208 << numberOfPeople <<
" leaves\n";
215 std::cout <<
"Ice Cream Store simulation from Chapter 9\n";
218 for (
unsigned t = 0;
t < 20;
t +=
irand (6)) {
220 std::cout <<
"pumping queue with event " <<
t <<
'\n';
228 <<
"\nEnd of ice cream store simulation\n";
arriveEvent(unsigned int t, unsigned int groupSize)
virtual void processEvent()
virtual void processEvent()=0
leaveEvent(unsigned int t, unsigned int groupSize)
virtual void processEvent()
orderEvent(unsigned int t, unsigned int groupSize)
virtual void processEvent()
std::priority_queue< event *, std::vector< event *, std::allocator< event * > >, eventComparator > eventQueue
void scheduleEvent(event *newEvent)
bool canSeat(unsigned int numberOfPeople)
void order(unsigned int numberOfScoops)
void leave(unsigned int numberOfPeople)
storeSimulation theSimulation
bool operator()(const event *left, const event *right) const
TOML_NODISCARD_CTOR time() noexcept=default
Default constructor. Does not initialize the members.