Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualMartins Mozeiko

Posted 22 April 2012 - 03:21 PM

bool operator()(const std::shared_ptr<SearchCell>& a, const std::shared_ptr<SearchCell>& b) const
		{
				if (a->get_f() <= b->get_f())
						return true;

				else if (a->get_f() > b->get_f())
						return true;
		}
I don't get this.
if A <= B then you return true, but if A > B then you also return true. So why bother comparing something - just return always true.

Edit: too late... :)

#2Martins Mozeiko

Posted 22 April 2012 - 03:20 PM

bool operator()(const std::shared_ptr<SearchCell>& a, const std::shared_ptr<SearchCell>& b) const
		{
				if (a->get_f() <= b->get_f())
						return true;

				else if (a->get_f() > b->get_f())
						return true;
		}
I don't get this.
if A <= B then you return true, but if A > B then you also return true. So why bother comparing something - just return always true Posted Image

#1Martins Mozeiko

Posted 22 April 2012 - 03:20 PM

        bool operator()(const std::shared_ptr<SearchCell>& a, const std::shared_ptr<SearchCell>& b) const
        {
                if (a->get_f() <= b->get_f())
                        return true;

                else if (a->get_f() > b->get_f())
                        return true;
        }
I don't get this.
if A <= B then you return true, but if A > B then you also return true. So you bother comparing something - just return true always :)

PARTNERS