I am new to the forum. Added comments, but cannot see them. So now I write here, so you can see I am not impolite.
About jamie's question: I need enumeration (I would like to have), e.g. [3000..4000] And cannot find operator for that. Actually also an "operator.." could be needed. But Anyway, with TBits I make a set-implementation and it runs this test-program:
// Main variable
var
i,j: integer;
s1: TVarSet; // First set
s2: TVarSet; // Second set
sx: TVarSet; // result set
// Main
begin
writeln('VarSet V0.900');
s1:=[3,5,7];
s2:=[13,15,17];
sx:=s1+s2;
// Different ways of adding elements
sx:=sx+10017;
include(sx,10000010);
include(s1,10000017);
include(s2,100000117);
// Union set run 100 times
for j:=1 to 100 do
sx:=s1+s2;
// Measure execution time for "For i in set"
for j:=1 to 100 do
begin
for i in sx do begin end;;
end;
writeln;
writeln('Expected output: ','3 5 7 13 15 17 10000017 100000117');;
write('Actual output: ');
for i in sx do begin write(i,' ') end;
writeln(chr(7));
readln;
end.
This seems to do the jobb. It uses TBits and runs surprisingly fast. Except for one thing: I need to free memory at assign. I write "operator:=(r: TVarSet; s: TVarSet), " But the compiler writes:
"Error: Impossible to overload assignment for equal types"
But that is what I need to free class at assignment.
My original text:
___________________________________
From the beginning of Pascal the size of a set is limited to 256 elements. The size has not been increased in 50 years.
I need bigger sets.
I was proposed to change the compiler but - I don't know where to begin. In the Facebook group (Free Pascal and Lazarus Foundation) I was told that the file '..../rtl/inc/compproc.inc' has a definition of length (Part of PFC).
The size may be "fpc_small_set" or "fpc_normal_set".
What would the effort be to increase this limit, remove the limit or make fpc_huge_set?
Alternative: Allow "[]" as an operator. Then all operators could be programmed.
To Set-haters: It does not harm you or offend you that I have a bigger set. You can just let let be using sets.