Saturday, December 28, 2013

Is It Possible...?

Newsgroup: comp.lang.c++

Subject: Is It Possible...?

From: mrc2323@...

Date: Sat, 28 Dec 2013 07:31:50 -0700



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



---

This email is free from viruses and malware because avast! Antivirus protection is active.

http://www.avast.com









via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?160251-Is-It-Possible&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums

No comments:

Post a Comment