Sorting records using sort()
From: Elijah Bailey (geomrock_at_hotmail.com)
Date: 12/31/03
- Next message: Dave: "Inexplicable error with std::string"
- Previous message: Alexander Stippler: "template instantiation trouble"
- Next in thread: Peter Koch Larsen: "Re: Sorting records using sort()"
- Reply: Peter Koch Larsen: "Re: Sorting records using sort()"
- Reply: Bo Persson: "Re: Sorting records using sort()"
- Reply: Ron Natalie: "Re: Sorting records using sort()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 31 Dec 2003 08:12:42 -0500
I want to sort a set of records using STL's sort() function,
but dont see an easy way to do it.
I have a
char *data;
which has size mn bytes where m is size of the record and
n is the number of records. Both these numbers are known
only dynamically. I have a function less_than that can compare
two records of size m given the pointers to the two records.
Is there an easy way to call STL sort() on this data and sort it.
The data is big and I do NOT want to allocate a list of pointers
of size n or anything linear in size. Assume that except the data,
we do not have much space...
I thought of tricking sort() using a dummy Record class that is
templated using the size of the record...But since m can change
dynamically this doesnt work.
Thanks in advance for your comments,
--Elijah
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
- Next message: Dave: "Inexplicable error with std::string"
- Previous message: Alexander Stippler: "template instantiation trouble"
- Next in thread: Peter Koch Larsen: "Re: Sorting records using sort()"
- Reply: Peter Koch Larsen: "Re: Sorting records using sort()"
- Reply: Bo Persson: "Re: Sorting records using sort()"
- Reply: Ron Natalie: "Re: Sorting records using sort()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|