-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUPOINTS.PAS
80 lines (66 loc) · 1.45 KB
/
UPOINTS.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
UPoints Unit
2022 LRT
}
unit
UPoints;
interface
uses
consts, utils, uclasses, types, locale,
uobject, uexc, math;
type
PPoints = ^TPoints;
TPoints = object (TObject)
public
constructor initWithSize(size: word);
destructor done; virtual;
function getClassName: string; virtual;
function getClassId: word; virtual;
procedure add(x, y: integer);
procedure get(var first: PPoint; var length: word);
private
_size: word;
_length: word;
_points: PPoint;
end;
implementation
{ TPoints public }
constructor TPoints.initWithSize(size: word);
begin
inherited init;
_size := size;
_length := 0;
getMem(_points, sizeof(TPoint) * _size);
end;
destructor TPoints.done;
begin
freeMem(_points, sizeof(TPoint) * _size);
inherited done;
end;
procedure TPoints.add(x, y: integer);
var
p: PPoint;
begin
if _length = _size then exit;
p := _points;
inc(p, _length);
p^.x := x;
p^.y := y;
inc(_length);
end;
procedure TPoints.get(var first: PPoint; var length: word);
begin
first := _points;
length := _length;
end;
function TPoints.getClassName: string;
begin
getClassName := 'TPoints';
end;
function TPoints.getClassId: word;
begin
getClassId := C_CLASS_ID_Path;
end;
{ TPoints private }
{ Other }
end.