I have to compare a value, if the value is less or equal than 3, then do something, if value is bettwen 4 and 27, then do something else, but if the value is more than 28 do something else, is there any elegant way which doesn’t consume a lot of resources and I can avoid using switch of if?? I have to compare around 60k+ values.
Share
I don’t think there is anything faster. You may be able to speed things up a little if you know how your data is distributed. For example, if most values are above 27 then check for that condition first, etc. If your data was sorted, you could also find a way to take advantage of that.