Image

Imagetimv wrote in Imagecpp

STL: Vector & Algorithm help, please...


//compute weighted Latitude and Longitude -- this works fine...

cout << "Computing Weighted Latitude and Longitude..." << endl;
for_each(zcd.begin(), zcd.end(), mem_fun_ref(&ZipCodeData::SetWLatLong));


//set distance from first zip code - I would like to learn how to use 
//  for_each with a member function here...but I can't quite figure 
//  it out.  I have tried various bind1st type stuff.  Any ideas?

cout << "Computing Distance from First Zip Code..." << endl;
ZipCodeData zcc = *zcd.begin();
vector::iterator i = zcd.begin();
while ( i != zcd.end() )
{
        i->SetDist(zcc);
        i++;
}


//sort zip codes - this works fine, but again, I would like to learn 
//  how to use a member function.

cout << "Sorting Zip Codes..." << endl;
sort(zcd.begin(), zcd.end(), CompDist);