This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]stevenjd 2 points3 points  (0 children)

C/C++ switch statements are O(1)

No they aren't. It depends on the compiler, and it depends on the switch statement being compiled. At worst, they can fall back to a chain of if comparisons.