Re: Set limitations

Hairy Pixels via fpc-pascal <[email protected]>
Newsgroups gmane.comp.compilers.free-pascal.general
Message-ID <CAGsUGt=GrgsR59c_xMW0ZPmm7N=DGjbhi4Dusz_toYzUb+=9dQ@mail.gmail.com>
 On Jan 11, 2025 at 10:53:36 PM, Sven Barth via fpc-pascal <
[email protected]> wrote:

> 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.
>

I did not know this existed. I don’t see any reason they force the set to 4
bytes unless it was being used to pass to C libraries maybe?


> 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.
>

Theoretically if you added one more element to 257 the size would double to
64 bytes right? That’s still only 50% of a short string both of which can
be sparsely populate so how are they different?

Regards,
    Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.