Just a note for this video that I think is important to point out. Apart from the switch statement being more elegant, it is also more efficient, especially when you have lots of cases. The reason being, a switch statement is generally implemented with a hash table or a similar data structure, giving you (ideally) an O(1) time complexity to get through the switch. With an if statement, worst-case scenario, you have to compare your variable to every single case, leaving you with an O(n) time complexity, n being the number of cases, which can be slow.
There's one drawback to the switch statement that's quite important, and that is the fact that the cases in the statement must be compile-time constants. So if you get errors that a variable is not usable in a constant expression or the compiler complains about a call to a non-constexpr function, that's why.
Switch statements create jump tables when they are compiled into machine code, for a huge list that, let's say is running 165 times a second in a list of 1000 items, this performance improvement can be EXTREME
Just a note for this video that I think is important to point out. Apart from the switch statement being more elegant, it is also more efficient, especially when you have lots of cases. The reason being, a switch statement is generally implemented with a hash table or a similar data structure, giving you (ideally) an O(1) time complexity to get through the switch. With an if statement, worst-case scenario, you have to compare your variable to every single case, leaving you with an O(n) time complexity, n being the number of cases, which can be slow.
Hence why I'm here. Someone I loathe refuses to use these, and has pages of if/else. I want to be nothing like him, so I'm doubling down.
Can’t wait for the more advanced stuff! Amazing series so far, probably the best 👀
Keep it up, Tim!
There's one drawback to the switch statement that's quite important, and that is the fact that the cases in the statement must be compile-time constants. So if you get errors that a variable is not usable in a constant expression or the compiler complains about a call to a non-constexpr function, that's why.
Like how you go very in depth to everything em explain everything all the way through
I have finally got ther confirmation for vectors, pointers and refferences, which is what I was waiting for in the series
Finally, the tutorial YandereDev need to watch the most LMAO XDD
I was waiting for new c++ lesson 😁😁😁
Switch statements create jump tables when they are compiled into machine code, for a huge list that, let's say is running 165 times a second in a list of 1000 items, this performance improvement can be EXTREME
Nice this one is just like the match case in python
Thanks for you content Tim ;)
My education system failed, this youtube man excelled
What chair are you using dude?
Switch statement can't use string a.k.a "std::string" and C string a.k.a "const char*" as expression.
yes tim!
ty
Tim! Which degree are you doing Bsc (computer science) or Btech (computer science)
How much focus will you be putting on creating graphics or seperate windows in future videos?
So, this is similar to SQL's CASE statement, right? Don't need it but is better than IF ELSE in some cases.
Thank ya)
Can you make more pygame and tutorials please in python.
pls make video 5 ideas for game in pygame
Cool
❤
huzzah
Bro can u please explain about power shell please bro i need it please🙏🙏🙏🙏
What are you looking to do with PS
2nd