unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Test: TButton;
procedure TestClick(Sender: TObject);
private
procedure SetElement(Vector: PDouble;
Index: Integer; Value: Double);
function GetElement(Vector: PDouble;
Index: Integer): Double;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.SetElement(Vector: PDouble;
Index: Integer; Value: Double);
begin
Inc(Vector,
Index);
Vector^ := Value;
Dec(Vector,
Index);
end;
function TForm1.GetElement(Vector: PDouble;
Index: Integer): Double;
begin
Inc(Vector,
Index);
Result := Vector^;
Dec(Vector,
Index);
end;
procedure TForm1.TestClick(Sender: TObject);
var
TestVector: PDouble;
begin
GetMem(TestVector, 20 * SizeOf(PDouble));
Self.SetElement(TestVector, 10, 0.1);
ShowMessage(FloatToStr(Self.GetElement(TestVector, 10)));
ShowMessage(FloatToStr(Self.GetElement(TestVector, 10)));
assert(Self.GetElement(TestVector, 10) = 0.1);
FreeMem(TestVector, 20 * SizeOf(PDouble));
end;
end.