Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-06

how to expand a set?

7 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

what is the best/easiest way to increase the size of a set if the set is defined as the following?

   const
     CMaxCount  = 255;
   type
     TMsgAreas  = set of 0..CMaxCount;
   var
     MsgAreas   : TMsgAreas;

is a set of sets possible?
how is a set of sets defined?
how are the elements in the sets accessed?

NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted.
Marco van de Voort
to Unknown author

In our previous episode, said:

what is the best/easiest way to increase the size of a set if the set is defined as the following?
Uses classes.tbits
Santiago A.
to Unknown author: what is the best/easiest way to increase the size of a set if the set is defined as the…
Show quoted text 16 lines
what is the best/easiest way to increase the size of a set if the set is defined as the following? const CMaxCount = 255; type TMsgAreas = set of 0..CMaxCount; var MsgAreas : TMsgAreas; is a set of sets possible?

No, the base type of a set must be an ordinal type. Enumeration type and integers. And the base type can't have more 255 elements

how is a set of sets defined?

No

how are the elements in the sets accessed?

??
What do you mean with "access"?
You can't access the element of a set, you can say if the an element is in a set or not.

msgAreas:=[1..7];

if (2 in msAreas) then .......

Saludos Santiago A.
Unknown author
to Santiago A.
Santiago A. wrote 19 lines
El 15/06/2016 a las 15:55, escribió: > > what is the best/easiest way to increase the size of a set if the set > is defined as the following? > > > const > CMaxCount = 255; > > type > TMsgAreas = set of 0..CMaxCount; > > var > MsgAreas : TMsgAreas; > > > is a set of sets possible? No, the base type of a set must be an ordinal type. Enumeration type and integers. And the base type can't have more 255 elements

right... so a set has 0-255 elements and a set of sets would have 0-255 elements containing one set of 0-255 elements... if all are used, that gives 0-65535 elements we can access... or should be able to access... if we can figure out how to create it :(

> how is a set of sets defined? No

hunh?

Show quoted text 5 lines
> how are the elements in the sets accessed? ?? What do you mean with "access"? You can't access the element of a set, you can say if the an element is in a set or not.

exactly... that's accessing it if it exists in the set...

msgAreas:=[1..7]; if (2 in msAreas) then .......

yup...

   if (this.messages.area.num in UsersMsgTaggedAreas) then
     begin
       ScanForNewMessages(this.messages.area.num);
       ScanForUserMessages(this.messages.area.num,this.user.name,this.user.nick);
     end
   else
     inc(this.messages.area);
  ;)
NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted.
Unknown author
to Marco van de Voort: In our previous episode, said: Uses classes.tbits
Marco van de Voort wrote 5 lines
In our previous episode, said: > what is the best/easiest way to increase the size of a set if the set is > defined as the following? Uses classes.tbits

nice! we used to do bit flags back in the TP/BP days but i forget how all that worked... this may be very handy :)

NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted.
Sven Barth
to Unknown author: right... so a set has 0-255 elements and a set of sets would have 0-255 elements…
Show quoted text 25 lines
On 06/15/2016 10:36 AM, Santiago A. wrote: > El 15/06/2016 a las 15:55, escribió: >> >> what is the best/easiest way to increase the size of a set if the set >> is defined as the following? >> >> >> const >> CMaxCount = 255; >> >> type >> TMsgAreas = set of 0..CMaxCount; >> >> var >> MsgAreas : TMsgAreas; >> >> >> is a set of sets possible? > No, the base type of a set must be an ordinal type. Enumeration type and > integers. And the base type can't have more 255 elements right... so a set has 0-255 elements and a set of sets would have 0-255 elements containing one set of 0-255 elements... if all are used, that gives 0-65535 elements we can access... or should be able to access... if we can figure out how to create it :(

A set is internally a bitfield of a maximum of 256 bits (or 32 bytes), so you *can't* nest them.

Regards,
Sven

Santiago A.
to Unknown author: right... so a set has 0-255 elements and a set of sets would have 0-255 elements…
Show quoted text 5 lines
>> how is a set of sets defined? > No hunh?

I meant, you can't. A set is not an ordinal type, but an structured type, so a set of sets is impossible.

Show quoted text 14 lines
yup... if (this.messages.area.num in UsersMsgTaggedAreas) then begin ScanForNewMessages(this.messages.area.num); ScanForUserMessages(this.messages.area.num,this.user.name,this.user.nick); end else inc(this.messages.area); ;)

That will work as long as UsersMsgTaggedAreas is restricted to 256 different values or less.
And, not sure, but I think if num is out of the range of values of UsersMsgTaggedAreas's base type then the 'in' test won't result true or false, but an error.

Saludos Santiago A.