BraK
2011-12-13 19:13:58
It will probably never make it into SIMBA but here is my ClearSameIntT2D procedure. All it does is go through all the Integer arrays in the T2D Array compare them to each other as well as the previously deleted integers and clear out all like integers. I doesn't just get rid of duplicates it completely deletes any and all like integers.
@euphemism This is the first step towards my project we talke about the other night. ;)
Below is the test script for the procedure it will not have the writelns in the used version. I attached the test script in a .simba file for ease.
Any feedback is very much appreciated.
@euphemism This is the first step towards my project we talke about the other night. ;)
Below is the test script for the procedure it will not have the writelns in the used version. I attached the test script in a .simba file for ease.
Any feedback is very much appreciated.
program T2DIntClearSame;
var
Test, T2I: T2DIntegerArray;
procedure ClearSameIntT2D(var T2DArray: T2DIntegerArray);
var
I, II, III: Integer;
ArrayOut: T2DIntegerArray;
DeleteSet: TIntegerArray;
begin
For I := 0 to High(T2DArray) do
ClearSameIntegers(T2DArray[I]);
SetArrayLength(ArrayOut, Length(T2DArray));
Writeln('Starting T2D Array After ClearSameIntegers := ' + tostr(T2DArray));
for I := 0 to High(T2DArray) do
for II := 0 to High(T2DArray[I]) do
for III := 0 to High(T2DArray) do
If I = III then
continue
else if InIntArray(T2DArray[III],T2DArray[I][II]) or InIntArray(DeleteSet, T2DArray[I][II]) then
begin
SetArrayLength(DeleteSet, Length(DeleteSet) + 1);
DeleteSet[Length(DeleteSet) - 1] := T2DArray[I][II];
end else
begin
SetArrayLength(ArrayOut[I], Length(ArrayOut[I]) + 1);
ArrayOut[I][Length(ArrayOut[I]) - 1] := T2DArray[I][II];
end;
ClearSameIntegers(DeleteSet);
writeln('Deleted Integers := ' + tostr(DeleteSet));
For I := 0 to High(ArrayOut) do
ClearSameIntegers(ArrayOut[I]);
T2DArray := ArrayOut;
end;
begin
SetArrayLength(T2I, 3);
T2I[0] := [1,1,2,4,4,5,6];
T2I[1] := [2,3,4,5,5,9,9];
T2I[2] := [2,4,6,7,8,8];
ClearSameIntT2D(T2I);
writeln('Output T2D Array := ' + tostr(T2I));
end.