I think little and came to conclusion, that changes about which you wrote me
on Monday (11 / 11 / 2013) via Skype:

 

        if (message.time() >= allowed_time)

          message.WriteTo(ofs_);

 

aren't correct also.

 

The condition "drop message, if it's time <= (Tmax - 2)"  put some
restrictions on messages with time = 0 or 1. So, all messages with time == 0
will be skipped, the same for messages with time == 1, until message with
time == 2 will become.

Let's consider following hypothetical situation - flow of messages in random
order of birth time:

 

t = 0 : reject (Tmax == 0, Tmax - 2 is undefined, because time is stored in
u32-variable), but we should accept this message !

t = 0 : the same

t = 1 : reject (Tmax == 1, Tmax - 2 is undefined, because time is stored in
u32-variable), but we should accept this message !

t = 0 : reject (Tmax == 1, Tmax - 2 is undefined, because time is stored in
u32-variable), correct.

t = 0 : the same.

t = 0 : the same.

t = 2 : accept (Tmax == 2, Tmax - 2 == 0, (t <= (Tmax - 2)) == false),
correct.

t = 2 : accept (Tmax == 2, Tmax - 2 == 0, (t <= (Tmax - 2)) == false),
correct.

t = 0 : reject (Tmax == 2, Tmax - 2 == 0, (t <= (Tmax - 2)) == true),
correct.

t = 1 : accept (Tmax == 2, Tmax - 2 == 0, (t <= (Tmax - 2)) == false),
correct.

t = 2 : accept (Tmax == 2, Tmax - 2 == 0, (t <= (Tmax - 2)) == false),
correct.

t = 3 : accept (Tmax == 3, Tmax - 2 == 1, (t <= (Tmax - 2)) == false),
correct.

t = 2 : accept (Tmax == 3, Tmax - 2 == 1, (t <= (Tmax - 2)) == false),
correct.

 

 

 

 

 

  _____  

From: Ivan Sidarau [mailto:notifications@github.com] 
Sent: Monday, November 11, 2013 2:18 PM
To: sidorovis/cpp_craft_1013
Cc: PeterMoroz
Subject: Re: [cpp_craft_1013] Puzzles 2 review (#148)

 

In solutions/peter_moroz/puzzles-2/sources/task-24/Task24.cpp:

> +    throw logic_error(message.str());
> +  }
> +
> +  boost::uint32_t max_time = 0;
> +  boost::uint32_t allowed_time = 0;
> +  Message message;
> +  message.ReadFrom(ifs_);
> +  while (!ifs_.eof()) {
> +    // filter messages here
> +    if (IsAllowedMessageType(message.type())) {
> +      if (message.time() > max_time) {
> +        max_time = message.time();
> +        allowed_time = max_time > 2 ? max_time - 2 : max_time;
> +        message.WriteTo(ofs_);
> +      } else {
> +        if (message.time() > allowed_time)

the same problem with business logic

-
Reply to this email directly or view
<https://github.com/sidorovis/cpp_craft_1013/pull/148/files#r7557545>  it on
GitHub.
<https://github.com/notifications/beacon/O7y4LvL-5wBGMo5Tflvq1vhHyVOSqy30Q4A
0XXLVV5CyPqTtU9BIwtZCvBCXnjVH.gif>