BooleanArray with size larger than 2147483647

I am trying to implement the sieve of Atkin in Kotlin. I want it to support numbers up to 2^32-1, so the sieve must be a UInt-indexed array.
I try to initialise the sieve like this:

var sieve = BooleanArray(limit + 1u)

Then, I get the error:

error: type mismatch: inferred type is UInt but Int was expected

So, is there any way of making a BooleanArray (or equivalent) store at least 4294967295 values?


Solution 1:

The most easy might be to use UInt as the size and then internally map 2 common BooleanArray, which use Int for addressing, despite there never could be a negative index value (this seems to be a design fault - or at least a lack of optimization). Which means, that one could as well address everything with signed Int. I mean, to internally map the negative values to one BooleanArray and the positive values to another one BooleanArray. The actual problem seems to be, that a signed Int is being passed, but only the positive range (50%) can be used to address data. One could use absoluteValue, because it doesn't matter in which direction the array is being filled.