I am trying to implement a radix sort in Swift (strictly out of boredom). I have been basing my work thus far on the C/C++ method found here.
For the most part everything is working as I would expect, except for one for loop which is giving me trouble.
for (int exp = 1; max / exp > 0; exp *= 10)
Swift no longer allows C style for loops so this won't fly. I have been trying to recreate the loop using several approaches including this:
var exp: Int = 1
for _ in (1..<(max / exp)).reversed()
{
//My code
exp = exp * 10
}
The problem here is Int
can't contain the size of exp
after several iterations of the loop. Since the original loop definition works just fine in Objective-C I believe my complete approach is flawed but I can't see where.
Any thoughts?