Class TBigByteArray (unit DynArrB)

Inherits from

TObject

Exports the TBigByteArray and TByteArray2D types. The TBigByteArray type is a dynamic array type, with Bytes as elements. Indexing the elements is done exactly like a normal array; the differences with a 'normal' array type are: - one MUST call the constructor to create the array - the size (no. of elements) of the array is determined at run time R.P. Sterkenburg, TNO Prins Maurits Laboratory, Rijswijk, The Netherlands 6 May 96: - created (unit name DynArrS) 7 May 96: - renamed property N to Count - added CopyInto method 13 May 96 - added Min & Max functions 14 May 96 - added inherited Create in constructor - added function FindMax and FindMinMax 12 Jul 96: - added function Average 23 Aug 96: - added procedure SortAscending 26 Aug 96: - added procedure MultiplyWith 9 Sep 96: - added various new procedures analogous to old unit bigarrays 7 Oct 96: - added TSingleArray.Subtract - corrected TSingleArray.Sum (check for NoValue added) 15 Nov 96: - replaced procedure CopyInto with function Copy 4 Dec 96: - added TSingleArray2D.Copy 16 Dec 96: - added TSingleArray2D.EqualTo 18 Dec 96: - added TSingleArray.Append 12 Feb 97: - corrected bugs in the Copy methods - added calls to inherited Create and Destroy in TSingleArray2D 21 Feb 97: - created as modified version of unit DynArrS which exported the TSingleArray (+2D) type - deleted methods CreateLinear, Average, GetMeanAndSigma, MultiplyWith 5 Mar 97: - added TByteArray2D.SetRow - made CopyRow a function - renamed TByteArray to TBigByteArray to prevent name conflicts with SysUtils' TBigByteArray 11 May 97: - made CopyRow more efficient by copying a block of bytes in stead of each element separately 14 Aug 97: - Deleted the System. scope-designator in SetRow, so that HeapUnit's Move procedure is called when necessary (again).

Constructors


constructor Create(N: Longint);

TBigByteArray.

constructor Dim(N: Longint);

TBigByteArray.

constructor ReadBinary(var F: File);

TBigByteArray.


Functions

procedure Append(appendarray: TBigByteArray);

TBigByteArray.

procedure Clear;

TBigByteArray.

function Copy: TBigByteArray;

TBigByteArray.

destructor Destroy;

TBigByteArray.

function EqualTo(OtherArray: TBigByteArray): Boolean;

TBigByteArray.

procedure FillWith(Value: Byte);

TBigByteArray.

procedure FindMax(var i: Longint; var max: Byte);

TBigByteArray.

procedure FindMinMax(var min, max: Byte);

TBigByteArray.

function Max: Byte;

procedure GetMeanAndSigma(var Mean, sd: Single);

TBigByteArray.


function Min: Byte;

TBigByteArray.

procedure Subtract(other: TBigByteArray);

procedure MultiplyWith(Factor: Single);} {procedure ReDim(NewSize: Longint);} {procedure SortAscending;

TBigByteArray.


procedure WriteBinary( var F: File );

function Sum: Single;

TBigByteArray.


function GetVal(index: Longint): Byte;

TBigByteArray.

procedure SetVal(index: Longint; value: Byte);

TBigByteArray.

Properties

property Address : Pointer


property Count : Longint


property Value : Byte


Events

Variables

FAddress : Pointer;


FCount : Longint;



Constructors


constructor Create(N: Longint);

TBigByteArray.ReDim } (***** methods of TBigByteArray


constructor Dim(N: Longint);

TBigByteArray.Destroy


constructor ReadBinary(var F: File);

TBigByteArray.Min } (*procedure TBigByteArray.MultiplyWith(Factor: Single); { Multiplies all elements values with factor } var i: Longint; v: Single; begin { TBigByteArray.MultiplyWith } for i := 1 to Count do begin v := Value[i]; if v <> NoValue then Value[i] := v * Factor; end; end; { TBigByteArray.MultiplyWith


Functions


procedure Append(appendarray: TBigByteArray);

TBigByteArray.SetVal } (***** end of the field access methods


procedure Clear;

TBigByteArray.Append } (*function TBigByteArray.Average: Single; var sum: Single; i, N: Longint; begin { TBigByteArray.Average } sum := 0; N := 0; for i := 1 to count do begin if Value[i] <> NoValue then begin Inc(N); sum := sum + Value[i]; end; end; if N <> 0 then Average := sum / N else Average := NoValue end; { TBigByteArray.Average


function Copy: TBigByteArray;

TBigByteArray.Clear


destructor Destroy;

TBigByteArray.Create


function EqualTo(OtherArray: TBigByteArray): Boolean;

TBigByteArray.Copy


procedure FillWith(Value: Byte);

TBigByteArray.EqualTo


procedure FindMax(var i: Longint; var max: Byte);

TBigByteArray.FillWith


procedure FindMinMax(var min, max: Byte);

TBigByteArray.FindMax


function Max: Byte;

procedure GetMeanAndSigma(var Mean, sd: Single);

TBigByteArray.FindMinMax } (*procedure TBigByteArray.GetMeanAndSigma(var Mean, sd: Single); { calculates mean and standard deviation of elements } var i, N: longint; value, Sum, SumOfSquares, MeanOfSquares: single; begin { TBigByteArray.GetMeanAndSigma } SumOfSquares := 0; Sum := 0; N := 0; for i := 1 to Count do begin value := GetVal(i); if Value <> NoValue then begin Inc(N); Sum := Sum + value; SumOfSquares := SumOfSquares + sqr(value); end; end; if N = 0 then begin Mean := NoValue; Sd := NoValue; end else begin Mean := Sum / N; MeanOfSquares := SumOfSquares / N; if (MeanOfSquares - Sqr(Mean)) < 0 { should only be possible } then sd := 0 {in case of rounding off errors } else sd := Sqrt( MeanOfSquares - Sqr(Mean) ); end end; { TBigByteArray.GetMeanAndSigma


function Min: Byte;

TBigByteArray.Max


procedure Subtract(other: TBigByteArray);

procedure MultiplyWith(Factor: Single);} {procedure ReDim(NewSize: Longint);} {procedure SortAscending;

TBigByteArray.ReadBinary } (*procedure TBigByteArray.ReDim(NewSize: Longint); var SelfCopy: TBigByteArray; TotalSize: Longint; begin { TBigByteArray.ReDim } TotalSize := Count * SizeOf(Byte); SelfCopy := Self.Copy; Self.Free; Create(NewSize); Move(SelfCopy.FAddress^, FAddress^, TotalSize); SelfCopy.Free; end; { TBigByteArray.ReDim }*) (* procedure TBigByteArray.SortAscending; { sorts the array ascending; may also be used for more than one-dimensional dynamicarrays } PROCEDURE store_tree( root: nodepointer; destination: TBigByteArray; VAR currentindex: longint); BEGIN { store_tree } IF root <> Nil THEN BEGIN store_tree(root^.ltree, destination, currentindex); destination[currentindex] := root^.value; Inc(currentindex); store_tree(root^.rtree, destination, currentindex); END; END; { store_tree } VAR tree: avltreetype; i: longint; newvalue, treeval: nodepointer; begin { TBigByteArray.SortAscending } tree.init; FOR i := 1 TO Count DO BEGIN tree.insert(Value[i]); {progressproc(0.8*i/nr_of_elements);} { Not up to 100% because tree.done requires some time too } { Tested: progressproc can take 50% of total time! } END; i := 1; { must be a var-parameter for store_tree } store_tree(tree.root, self, i); tree.done; {progressproc(1);} end; { TBigByteArray.SortAscending }


procedure WriteBinary( var F: File );

function Sum: Single;

TBigByteArray.Subtract } (*function TBigByteArray.Sum: Single; { Returns the sum of the values of the elements } var i: Longint; s: Single; begin { TBigByteArray.Sum } s := 0; for i := 1 to Count do if GetVal(i) <> NoValue then s := s + GetVal(i); Sum := s; end; { TBigByteArray.Sum


function GetVal(index: Longint): Byte;

TBigByteArray.Dim } (***** end of constructors and destructors *****) (***** field access methods


procedure SetVal(index: Longint; value: Byte);

TBigByteArray.GetVal


Properties


property Address : Pointer


property Count : Longint


property Value : Byte


Events


Variables


FAddress : Pointer;


FCount : Longint;