[fpc-pascal] Elegant way to switch sort mechanism in TSortedCollection?
Jim Leonard
trixter at oldskool.org
Thu Mar 13 15:56:35 CET 2014
On 3/13/2014 9:49 AM, Jim Leonard wrote:
> On 3/12/2014 6:58 PM, Philippe wrote:
>> you could
>>
>> - store the actual collection to a TMemoryStream,
>>
>> - destroy the collection,
>>
>> - Load then a new collect to be sort with different method ...
>
> Yes, that's what I'm doing now for every re-sort.
Actually, sorry, that's not *exactly* what I'm doing -- I'm creating a
new TSortedCollection, using ForEach to iterate through the old
collection to Insert into the new one, and then destroying the old one.
This copies only pointers (and runs through the Compare method) and is
actually pretty fast -- it's just not elegant.
If I stored the entire thing to a memory stream, it would copy all of
the data and every re-sort would go pretty slowly.
--
Jim Leonard (trixter at oldskool.org)
Check out some trippy MindCandy: http://www.mindcandydvd.com/
A child borne of the home computer wars: http://trixter.oldskool.org/
You're all insane and trying to steal my magic bag!
More information about the fpc-pascal
mailing list