After several rounds of testing, I found that when algorithms based on the the deletion of individual Worksheet rows are used, the execution time seems to increase nonlinearly as the number of Worksheet rows increases. I have therefore developed an alternative approach based on the Worksheet sort function. This approach executes more quickly and it seems that the execution time increases linearly with the number of worksheetwors. The code listed below is is an OriginC approach with which the following performance is typical on my workstation ...
Worksheet size = 200000 rows ... execution time ~1.35 sec
Worksheet size = 2000000 rows ... executiontime = 14.6 sec
By way of comparison approaches based on the deletion of individual worksheet rows gives the following results
Worksheet size = 25000 rows ... execution time ~13 sec
Worksheet size = 200000 rows ... execution time ~105 sec
bool DeleteAltRows(int StartNum)
{
Worksheet Wks(Project.ActiveLayer());
if(Wks.IsValid()==true && StartNum>=0 && StartNum<Wks.GetNumRows())
{
waitCursor Deleting;
vector<uint> RowIndices;
uint NumRows=Wks.GetNumRows();
RowIndices.SetSize(NumRows);
RowIndices.Data(0,NumRows-1,1);
int NumToDelete=0;
for(int i=StartNum+1;i<NumRows;i+=2)
{
RowIndices[i]+=NumRows;
NumToDelete++;
}
string strTemp="rnInsert";
string strTemp1;
if(Wks.InsertCol(0,strTemp,strTemp1)==false) return false;
Dataset dS0;
if(dS0.Attach(Wks,0)==true)
{
dS0.SetSize(NumRows);
dS0=RowIndices;
Wks.Sort();
if(Wks.SetNumRows(NumRows-NumToDelete)==true )
{
if(Wks.DeleteCol(0)==true)
{
return (true);
}
}
}
}
return (false);
}