When I use the sort routine for a vector of Ereignis
class instances, I am comparing some private members in this routine. As I don't have a direct access to them, I am using public methods instead:
bool sort(Ereignis *ereignis1, Ereignis *ereignis2)
{
if (ereignis1->DatumHolen() < ereignis2->DatumHolen())
return true;
else if (ereignis1->DatumHolen() == ereignis2->DatumHolen())
{
if (ereignis1->VeranstaltungHolen()->RangfolgeAmGleichenTagHolen() < ereignis2->VeranstaltungHolen()->RangfolgeAmGleichenTagHolen())
return true;
}
return false;
}
//---------------------------------------------------------------------------
stable_sort(ereignisse.begin(), ereignisse.end(), sort);
Is this really a good practice? I mean, STL methods have been designed to work in a very fast way. For that reason it would make more sense to use the private members directly instead of loosing some time accessing the public methods instead.