Re: Sorting records using sort()
From: Elijah Bailey (geomrock_at_hotmail.com)
Date: 1 Jan 2004 10:46:26 -0800
Is there no easy way to solve this problem??
I dont want to use qsort from C...! I cant figure
out how to even write a random access iterator
for this problem. What will be its value type?
I would like to swap the records to sort them,
not copy keys and sort them separately...
Thanks in advance for your help,
email@example.com (Elijah Bailey) wrote in message news:<firstname.lastname@example.org>...
> 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,
> [ See http://www.gotw.ca/resources/clcm.htm for info about ]
> [ comp.lang.c++.moderated. First time posters: Do this! ]