i Want to create a bit array , size [1...1E6, 1...1E6] or even a little bit bigger. .-))

I used a TList Object and a Bool-Pointer

max. array size is only 1E5x1E5 . Any Hint thow o blow up my record size?

the function TBitplane.Init_BitArray should run with stepx=1E6.. and function stepy=1E6...

------------------

some trial code

------------------

type

TPointBoolZ = record

// x : Integer; { x index = 0...n, removed, changed to lin. Address }

// y : Integer; { y index = 0...m, removed, changed to lin. Address }

Z : Boolean;

end;

TPointBoolZPtr =^TPointBoolZ;

{ 2D Array of Bool to calc the area of any arbitray gemomatical layouts }

TBitPlane = Class

BitArray : TList;

constructor Create;

private

Upp : FPoint;

Low : FPoint;

deltax : Real;

deltay : Real;

stepX : Integer;

stepY : Integer;

{ Function for discrete geometric (DG) problems }

public

function Init_BitArray : Boolean;

function AddTRect(MyRect : TRect) : Boolean;

function AddTFRect(MyFRect : TFRect) : Boolean;

function AddTCircle(MyRect : TRect) : Boolean;

function AddFCircle(MyFRect : TFRect) : Boolean;

function AddTThickline(MyLine: TThickline): Boolean;

function GetTIndex (MyPoint :FPoint): TPoint;

function GetFPoint (MyPoint :TPoint): FPoint;

function VirtualPoint(I: Integer): TPoint;

function AssignSize(UpperCorner, LowerCorner : FPoint; Sx, Sy : Integer) : Boolean;

function SetBitArray (x,y : Integer; Value : Boolean) : Boolean;

function GetBitArea: real;

function GetFalseCount : Integer;

function GetBitArray(x, y: Integer): Boolean;

end;

{ Calculate from the 1D Array of Bool to 2d Array A[X;Y] }

function TBitplane.VirtualPoint(I : Integer): TPoint;

var V : TPoint;

x,y : Word;

begin

// procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: Word);

DivMod(i, stepx,y,x);

V.x :=x;

V.y :=y;

result := v;

end;

function TBitplane.Init_BitArray : Boolean;

var x, y : Integer;

SinglePoint : TPointBoolZPtr;

begin

BitArray.Clear;

try

begin

for y:=0 to stepy do

for x := 0 to stepx do

begin

new(SinglePoint);

// SinglePoint^.x := x; { version 1 only }

// SinglePoint^.y := y; { version 1 only }

SinglePoint^.Z := false;

BitArray.Add(SinglePoint);

end;

result := true;

end;

except

result := false;

end;

end;

Lol... you do realize what you are asking, right?

1E6 (1 million) squared is 1E12, or 1 trillion bits. Even given the fact that you could compress this by 8 (8 bits / byte) and use 64 bit integer math to locate the desired byte at X,Y (and mod to determine the bit), eg:

1M rows / Each row at 125K (1M / 8) / Each byte of the row comprises 8 values

and you would still be faced with storing 125 GB of data to make up your array. Now also consider that the max address space of any user mode windows process is technically 2GB (possible to achieve up to 4gb), and you quickly see that you can only address 1.6% of the actual array in memory. This would mean using a 125 GB disk file as the actual storage backing for the array. So while theortically achievable, its not going to be fast, and you need a pretty beefy system with plenty of storage to handle this. And even on a fast disk, you would probably be looking @ roughly 1-2 hours to perform an Init(...) on your virtual array.

As far as what ziolko is recommending, it just does not apply here, as your process would hit the 2GB address limit before it even finished 0.2% of the array.

---

Russell