M
Mike Copeland
To "template-ize" a class/struct sort override? I have the following
structure:
struct RelayTeamType
{
time_t totalTime; // Total Time
int bib1, bib2; // Bib# #1 & Bib# #2
int numFins; // # Finishers
char ttc; // Team Type Code
string rtCode, rtTeamName;
string sortKey; // derived sort key
bool operator<(const RelayTeamType &a) const
{
return sortKey < a.sortKey;
}
} extern rtWork;
extern vector<RelayTeamType> rtVect;
extern vector<RelayTeamType>::iterator relIter;
Currently, I'm constructing the "sortKey" variable by passing through
the entire vector and using different variables in the struct (e.g.
"rtCode" or "totalTime", etc.), followed by the sort. This is simple
enough, but it takes processing time I want to avoid.
I'd like to be able to sort the vector on different fields, and it
would be nice if I could do it via a "template" interface. Is this
possible somehow? TIA
structure:
struct RelayTeamType
{
time_t totalTime; // Total Time
int bib1, bib2; // Bib# #1 & Bib# #2
int numFins; // # Finishers
char ttc; // Team Type Code
string rtCode, rtTeamName;
string sortKey; // derived sort key
bool operator<(const RelayTeamType &a) const
{
return sortKey < a.sortKey;
}
} extern rtWork;
extern vector<RelayTeamType> rtVect;
extern vector<RelayTeamType>::iterator relIter;
Currently, I'm constructing the "sortKey" variable by passing through
the entire vector and using different variables in the struct (e.g.
"rtCode" or "totalTime", etc.), followed by the sort. This is simple
enough, but it takes processing time I want to avoid.
I'd like to be able to sort the vector on different fields, and it
would be nice if I could do it via a "template" interface. Is this
possible somehow? TIA