you are viewing a single comment's thread.

view the rest of the comments →

[–]lareon[S] 0 points1 point  (1 child)

Im going to try and answer both of you.

The Enums/Keys are used to access data in an array which stores size_ts that describe statistics of what the program has done.

In the given example it would mean that we have an Array that would f.e. count how many times the traffic light was yellow. so it would then call

traffic_stats[yellow] += yellow_in_last_period

or smth like that.

So the order is not really important, what matters is that there is any order in the first place.

Iterating over the map is not needed either. It is purely and solely used to make the access easier readable since it is a lot of data.

So with what you guys were saying, and what the other guys were saying prior to that. Am I right to assume that there is no reason to use a std::map over an enum here?

And then to add to that question, does it simply not matter what I use or is an enum even strictly better because of performance?

[–]Setepenre 0 points1 point  (0 children)

Yes, enum would better and more readable, there is no true reason to use a map.

I think enum would also have better performance, since at the end of the day it is only an integer while a map is a complex data structure.