[fpc-pascal] Elegant way to switch sort mechanism in TSortedCollection?

Philippe philippe at quarta.com.br
Thu Mar 13 00:58:00 CET 2014


 

solution may depend on the way the collection is used. load once?
many inserts and deletes? ... the time you have to switch from one sort
to another ... and the size of the collection ... 

you could 

- store
the actual collection to a TMemoryStream, 

- destroy the collection,


- Load then a new collect to be sort with different method ...


2014-03-12 21:56 GMT+01:00 Jim Leonard <trixter at oldskool.org>:Em
12.03.2014 19:06, Frederic Da Vitoria escreveu: 

>> On 3/12/2014 2:30
PM, Philippe wrote:
>> 
>>> Type
>>> TMethod = ( method_type_1,
method_type_2, method_type_3);
>> 
>> Ah, clever -- create a Compare
that switches based on what I tell it to do. I like that, but as far as
I can tell there's no way to tell a TSortedCollection to "resort" --
it's kept sorted only through inserts and deletes.
> You (or the user)
will never need to resotre the first order? I am asking because you
could as well simply create one SortedCollection for each sort order and
systematically insert each item in all those collections. The overhead
would be in the initial loading, but then switching would be
instantaneous. 
> 
> -- 
> Frederic Da Vitoria
> (davitof)
> 
> Membre
de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org [2] 
> 
>
_______________________________________________
> fpc-pascal maillist -
fpc-pascal at lists.freepascal.org
>
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal [1]




Links:
------
[1]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[2]
http://www.april.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140312/7ba781e6/attachment.html>


More information about the fpc-pascal mailing list