I see ClearSameInteger and ClearSameIntegerAndTPA, but its not the same as what a ClearSameTPA would be. Has this been discussed? I sure it would be a useful addition to something like wizzy plugin.
Printable View
I see ClearSameInteger and ClearSameIntegerAndTPA, but its not the same as what a ClearSameTPA would be. Has this been discussed? I sure it would be a useful addition to something like wizzy plugin.
Compiled succesfully in 31 ms.Code:program new;
function clearsametpa(a: TPointArray): TPointArray;
var
b: TPointArray;
len, i, n: Integer;
switch: boolean;
begin
switch := false;
len := 0;
result := [];
setarraylength(b, length(a));
for i := 0 to high(a) do
begin
for n := 0 to high(b) do
begin
switch := a[i] = b[n];
if switch then break;
end;
if not switch then
begin
b[len] := a[i];
inc(len);
switch := false;
end;
end;
setarraylength(b, len);
result := b;
end;
var a, b: array of TPoint;
begin
a := [point(1, 1), point(2, 2), point(2, 2), point(3, 3), point(5, 3), point(5, 3), point(3, 5)];
b := clearsametpa(a);
writeln(a);
writeln(b);
end.
[(1, 1), (2, 2), (2, 2), (3, 3), (5, 3), (5, 3), (3, 5)]
[(1, 1), (2, 2), (3, 3), (5, 3), (3, 5)]
faster in plugin, and could be optimized?
edit: its damn slow on large sets.
ClearDoubleTPA?
Thanks.