Skip to content

Commit

Permalink
fix: read comments (#73)
Browse files Browse the repository at this point in the history
- `T2DPointArray.Smallest()` and `T2DPointArray.Biggest()` don't return an empty TPointArray anymore.
- Also added .First() and .Last() methods
  • Loading branch information
Torwent authored Feb 12, 2023
1 parent 406b80d commit 6f8f1a8
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions utils/tpointarrays.simba
Original file line number Diff line number Diff line change
Expand Up @@ -1377,20 +1377,44 @@ begin
Result[i] := GetTPABounds(Self[i]);
end;


function T2DPointArray.First(): TPointArray; constref;
begin
if Self <> [] then
Result := Self[0];
end;

function T2DPointArray.Last(): TPointArray; constref;
begin
if Self <> [] then
Result := Self[High(Self)];
end;


function T2DPointArray.Smallest(): TPointArray; constref;
var
TPA: TPointArray;
tpa: TPointArray;
begin
for TPA in Self do
if (Length(TPA) < Length(Result)) then
Result := TPA;
for tpa in Self do
begin
if Result = [] then
Result := tpa;

if (Length(tpa) < Length(Result)) then
Result := tpa;
end;
end;

function T2DPointArray.Biggest(): TPointArray; constref;
var
TPA: TPointArray;
tpa: TPointArray;
begin
for TPA in Self do
if (Length(TPA) > Length(Result)) then
Result := TPA;
for tpa in Self do
begin
if Result = [] then
Result := tpa;

if (Length(tpa) > Length(Result)) then
Result := tpa;
end;
end;

0 comments on commit 6f8f1a8

Please sign in to comment.