Maximum array size
Ivan Kazmenko
gassa at mail.ru
Wed Apr 26 07:19:20 PDT 2006
Ben Phillips:
>>>Why the need for such a large static array? Can't a dynamic array be used in
>>>your code instead?
>>I could use dynamic array, yes, but I don't see any benefit since its size is
>>fixed. Please explain why it could be better.
>Actually static arrays are fixed size and dynamic arrays are not.
I meant that the thing fixed is the size of my array, not the size of dynamic
array. Sorry for the ambiguity.
>An array is the wrong way to go if you need that much memory. Anyways, the
>Eratosphenes sieve is iterative so you could use a linked list instead. Since
>the extra 768M (*2 if doubly linked) links would increase the memory requirement
>by a large amount you could consider using a custom, hybrid collection. Maybe by
>having a linked list of arrays each with a size of 50000.
Well, lists are in no way related to the problem. Firstly, they are just too
slow. Secondly, for any number N, say, 1 <= N <= 100_000_000, I need to have a
fast way to check whether it is prime. When you need something to be done real
fast, using heavy data structures such as lists and collections doesn't make
sense.
The sieve is not the result of the algorithm; rather, it's an auxiliary table
built at initialisation time and used ever since.
Ivan Kazmenko.
More information about the Digitalmars-d
mailing list