[fpc-pascal] Set limitations
Sven Barth
pascaldragon at googlemail.com
Sat Jan 11 16:53:36 CET 2025
Hairy Pixels via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am
Sa., 11. Jan. 2025, 14:17:
> I was curious, is there any practical limit on the size of a set (32 bits
> and 256 values) and why they couldn’t be 64 bit or any other arbitrary
> size? The floor seems to be 4 bytes too but why not allow smaller sizes to
> save memory? Perhaps just a historical artifact but I was curious.
>
Set are a minimum of 4 Byte by default cause that's how Delphi does them.
Ifets you want smaller sets then use the $PackSets directive as Martin had
written.
The maximum is also based on what TP and Delphi allow. ISO Pascal for
example suggests a maximum of 1024 elements instead, though they define
this number to be implementation specific.
In the end it's a decision of where to do the cut as at some size the
majority of the set will be sparsely populated so it makes more sense to
use a dedicated type instead (e.g. a hash set or something like that) that
wastes less memory.
Regards,
Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20250111/eb032c3a/attachment.htm>
More information about the fpc-pascal
mailing list