Re: Set limitations
Sven Barth via fpc-pascal <[email protected]>
| Newsgroups | gmane.comp.compilers.free-pascal.general |
|---|---|
| Message-ID | <CAFMUeB8O6LTdMUod+nMr0CY55SoLeaNnxEStVO_tD5wz8KRpEg@mail.gmail.com> |
Hairy Pixels via fpc-pascal <[email protected]> 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 > _______________________________________________ fpc-pascal maillist - [email protected] https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal