LuigiPaolo

2014-11-30 20:34:46 UTC

Permalink

Sorry for my bad englishRaw Message

the code mentioned below is part of an algorithm

to generate the list of a chess tournament (a bit more complex than

football).

Everything is based on the SET of Delphi7 and ranking

works perfectly only if the players do not exceed the number of 255.

The problem is that the SET can not contain more than 255 items

while a chess tournament can be up to 400-500 participants

Therefore I'm forced to work with arrays.

Some time ago I was suggested to use the functions

Contains and Procedure SetBit and below, respectively, instead of the

clause INCLUDE and IN of SET, the friend who sent me has

and I have not tested despite many efforts have failed

to solve the problem.

This would replace the IN clause and INCLUDE functions

suitable arrays.

I would also like to know how do you empty an array, with the SET

enough Set1 [] or Set2 []

Thanks for those who can help me by giving me even just a few ideas

Voltolini Luigi

Italy

?

///////// Suggested Functions

type

TMySet = array [0..63] of Byte; // 86 bytes = 512 bits

Contains function (const S: TMyset; bit: integer): boolean;

begin

Result: = (S [bit div 8] and (1 shr (bit mod 8))) <> 0;

end;

procedure SetBit (var S: TMyset; bit: integer);

begin

S [bit div 8]: = S [bit div 8] or (1 shr (bit mod 8));

end;

//////

?

Working code with the SET that replace

with ARRAY ....

?

?

////// Set1, Set2: set of 1..255;

?

Player with [ColumnA] do

begin

if (ColumnB in Set1) then begin

Include (Set2, ColumnB)

end;

if not (ColumnB in Set1) then begin

Include (Set1, ColumnB);

end;

....

Player with [ColumnB] do

begin

if (ColumnA in Set1) then begin

Include (Set2, ColumnA)

end;

if not (ColumnA in Set1) then begin

Include (Set1, ColumnA);

end;