What is the implementation of the sets used in pascal?

I want to know the actual implementation of a given type in pascal provided by the language. Specifically, I would like to know the one used in the freepascal runtime library, but I am interested in any pascal implementation.

I care about the difficulty of doing it. Best Implementations A data structure with unrelated sets is in O (log * n) and I want to know if the pascal implementation has that.

The doc for fpc rtl is here: ftp://ftp.freepascal.org/pub/fpc/docs-pdf/rtl.pdf but it is too big (> 1700 pages) to search for it without knowing if it's even there. The wiki wiki does not shed light on this .

+3


source to share


2 answers


Consistent with this explanation , Pascal internally represents sets as bit strings. However, the article does not appear to be specific to Pascal's specific implementation. In this documentation also states that for the submission of bit lines are used. More precisely, this documentation explicitly mentions 32 bytes for storing the set.



+2


source


The Free Pascal language documentation is a reference ", rtl is a runtime guide. The compiler options and directives are in the programmer's guide, see the $ pack * links below.

Settings are bit fields that vary in size depending on the parameters. (e.g. $ packset and $ packenum ), up to a maximum size of 256 bits, 32 bytes (this is the old TP limit).

IIRC in (obj) FPC mode, sets grow using a dictionary, and in Delphi mode with size in bytes, but that's a little x86-centric. Size = 3 bytes is however not possible and will be rounded to 4.



The lower bound is always 0, so a set of 8..10 is 2 bytes (0..15), although it can only contain 3 values ​​(8,9,10).

In addition, there is also a bit of endian vs big endian issue. In systems with large ends, you cannot access the given fields one by one and in order. Afaik FPC mostly refers to them in Wordwise, but I've tested this for a long time.

+1


source







All Articles