About 'Introducing C# Queues'!

In this video (objectives)…

  1. Define FIFO vs LIFO queues
  2. Using Queue queue syntax
  3. Using Queue.Enqueue()
  4. Using Queue.Dequeue()
  5. Detecting when end waypoint is found.

After watching (learning outcomes)…

Add and remove items from a C# queue.

(Unique Video Reference: 14_RR_CU2)

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-forum (for the section)
  • Have the correct lecture tag.

Enjoy your stay in our thriving community!

I think I found the challenge in this one a bit confusing, in that it wasnt clear what we are trying to achieve.

I started off with “if (searchCentre == endWaypoint)…”, thinking that we want to know if the current position is the same as the endpoint.

However, I then realised Ben actually wanted us to check that the start and end are the same, so changed it to “if (startWaypoint == endWaypoint)…”, which does exactly what is asked, but isn’t useful (imo) if the search centre is going to change later.

Turns out I was right the first time, so assuming I didn’t just interpret the challenge incorrectly, it may be worth rewording it so we know we are trying to identify the endpoint (and end the loop) and not check that the start and end are the same (even though, at this point both arguments are true).

Of course, this is assuming that “searchCentre” is going to change as we progress through the search, but if its not and its just identifying where the search starts from (although, why? startWaypoint does that already), then Ill edit this later while looking embarrassed… :wink:

I think the point here is that we are creating a general stop condition for the search (i.e. the do while loop) that can cater for the special case where the start and end point are the same, as well as a normal end point where you do a search through the waypoints until finding a different endpoint. As it happens you don’t need any special code for when the start and end points are the same as the standard check can handle this condition since in that case you get the equivalent of your second piece of code:

“if (startWaypoint == endWaypoint)…”

I suspect that you may have been reading too much into the exercise. :slight_smile: It is really setting things up for subsequent lessons when we add more code to the PathFind function to actually search through the waypoint grid.

I think you are probably right… :smiley:

1 Like

I did the same thing firstly made something like that :

if (startWaypoint == endWaypoint)
{
print(“Start and end waypoints are the same, the algorytm will stop”);
break;
}

my question is why it can’t be just break; command ? Why we need to do the next bool variable ?

EDIT :
Ok i found the answer, we can use break; comand only if it is in the loop. If we do it in another method which is in the loop it is not gona work.

Privacy & Terms