Home

hi, i'm reading a binary data file, which is basically a list of 7296
offsets pointing to data blocks which represent scanlines containing
three numbers; leftx, id, rightx. i can read these fine and push them
into vectors using;

for (int a = 0; a < 7296; a++)
{
for (int c = 1; ; c=c+2)
{
province *temp_prov = new province;
cords *temp_cords = new cords;

file.seekg (4*(7296+(1*c)+offsets[a]));

file.read ((char *)&temp_cords->left, sizeof(short));
file.read ((char *)&temp_prov->id, sizeof(short));
file.read ((char *)&temp_cords->right, sizeof(short));
temp_cords->line = a;

temp_prov->lines.push_back (*temp_cords);
provinces.push_back (*temp_prov);

if (temp_cords->right == 18944)
{
delete temp_cords;
delete temp_prov;
break;
}
else
{
delete temp_cords;
delete temp_prov;
}
}
}

while ugly and most likely wrong, i /assure/ you it works. here is my
problem; i want to move the line data of all areas with a matching id
into one vector, and then remove them. i was thinking something like

for (int a = 0; a < provinces.size (); a++)
{
for (int b = 0; b < provinces.size (); b++)
{
if (provinces[a].id == provinces[b].id && a != b)
{
provinces[a].lines.push_back(provinces[b].lines[0]);
provinces.erase (provinces.begin()+b);
}
}
}

but this is SLOWER than slow and im sure its probably 100% wrong but
i'll never know because it apparently will takes hours to complete. i
should mention that the amount of elements in provinces is; 557,406.
any alternative approaches that'll let me do this quickly on a Pentium
3 800?

ps; if you want a better description of the file than i can provide
http://www.inferis.org/eu2/tbl/id.tbl.asp

previous
next

window messages to the wrong window
Re: can c++ deal with hardware??? - TPA
Re: Hot subject: a good python editor and/or IDE?
Re: Difference between two times (working ugly code, needs polish)
Re: looking for the fastest complex number arithmetics...
Archiwizacja danych
Bajki
cyklinowanie warszawa
forum
forum pokerowe