You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got a filter working on java, which transforms switch on string into switch on the string's hashcode, with support for collisions. It's not the best since the first time it has to calculate the string's hashcode, but if we cache the hashcode (like Java does), subsequent switches will be very fast
identify differences, best case is having a distinct char per string in one and the same position
simple case:
"ab"
"bc"
"aef"
"xhi"
switch on length of string and then switch on second char in above example, check whether we actually have a match and we have a result.
Edit: Uhm.. in this example we wouldn't need the switch on length, of course, but in the general case that's a good way to partition the strings into subsets.
While we can use an if-chain for small switches, it might make sense to look into some hash-based solution for larger ones.
The text was updated successfully, but these errors were encountered: