[fpc-pascal] Set size limit

Flávio Etrusco flavio.etrusco at gmail.com
Tue Mar 12 09:36:12 CET 2013


On Mon, Mar 11, 2013 at 10:54 AM, Daniel Gaspary <dgaspary at gmail.com> wrote:
> On Mon, Mar 11, 2013 at 10:43 AM, Jonas Maebe <jonas.maebe at elis.ugent.be> wrote:
>> A set is basically a bitpacked array of boolean. Element X is set to true if
>> you add X to the set, and to false if you remove it again. That means that
>> if you have a set with 600 possible values, you need at least 600 bits,
>> regardless of how many elements are inside it.
>>
>> The above also shows an alternative to sets in that case: you can use a
>> bitpacked array[TMyEnum] of boolean instead. Of course, then you can't use
>> the regular set operators.
>>
>> Jonas
>
> Your explanation made the implementation problem clear to me. And the
> alternative is interesting.
>
> Thank you.

I was going to raise the possibility of declaring more than one subset
using ranges, but I just noticed that
{{{
  TMySet = set of 300..305; .
}}}
doesn't compile. Isn't that supported by Delphi?

Best regards,
Flávio



More information about the fpc-pascal mailing list