Bart van den Broek wrote:
Why not add an overloaded CustomSort method that accepts the compare
function that you like.
Has the code duplication, maintenance, bloat, etc. problem.
Micha
___
fpc-devel maillist - fpc-devel@lists.freepascal.org
On Mon, 6 Nov 2006, Micha Nelissen wrote:
Hi,
Does anyone use the CustomSort facility of TStringList ? I am a bit
troubled because it's broken by design it seems. You can sort the list
with it, but searching/adding will not work properly (or be linear). I
want to have a callback that
Michael Van Canneyt wrote:
Ehm.
What has adding/searching to do with sorting ?
Adding: keep the list sorted.
Searching: ability to use binary search instead of linear.
Micha
___
fpc-devel maillist - fpc-devel@lists.freepascal.org
On Tue, 7 Nov 2006, Micha Nelissen wrote:
Michael Van Canneyt wrote:
Ehm. What has adding/searching to do with sorting ?
Adding: keep the list sorted.
Use Sorted:=True.
Searching: ability to use binary search instead of linear.
It is used if Sorted=True.
But not with customsearch.
Does anyone use the CustomSort facility of TStringList ? I am a bit
troubled because it's broken by design it seems. You can sort the list
with it, but searching/adding will not work properly (or be linear). I
want to have a callback that gives you two strings to compare, instead
of two
Michael Van Canneyt wrote:
The purpose of Customsearch is to sort the list once using a custom
sorting algorithm.
That reduces its usefulness, and why I said it's a broken design :).
Micha
___
fpc-devel maillist - fpc-devel@lists.freepascal.org
On Tue, 7 Nov 2006, Micha Nelissen wrote:
Michael Van Canneyt wrote:
The purpose of Customsearch is to sort the list once using a custom
sorting algorithm.
That reduces its usefulness, and why I said it's a broken design :).
Maybe, but it's implemented to be delphi compatible.
What
Chris Cheney wrote:
Stating the obvious: but the programmer might wish to sort by the objects
or by some combination of the strings and the objects (or even by entries
in an external array, unrelated to the StringList) - the indexes are
therefore needed in the general case.
Oh right, sorting
On Tuesday 07 November 2006 09:17, Micha Nelissen wrote:
Chris Cheney wrote:
Of course, the efficient way to build a sorted list is to set
Sorted to False and to sort the list after all the items have been
added.
It doesn't matter in O-time: both are O(n log n). Nevertheless, you
On Tue, 07 Nov 2006 10:17:24 +0100
Micha Nelissen [EMAIL PROTECTED] wrote:
Chris Cheney wrote:
Stating the obvious: but the programmer might wish to sort by the
objects or by some combination of the strings and the objects (or
even by entries in an external array, unrelated to the
Vinzent Hoefler wrote:
It doesn't matter in O-time: both are O(n log n). Nevertheless, you
probably will save some function call overhead.
That highly depends on the sorting algorithm used. A plain Quicksort has
a very bad worst case of O(n**2) that develops especially when the list
to be
Does anyone use the CustomSort facility of TStringList ?
It's delphi compat.
I am a bit troubled because it's broken by design it seems. You can sort
the list with it, but searching/adding will not work properly (or be
linear).
Why would you want to add/search while sorting?
Marco van de Voort wrote:
I am a bit troubled because it's broken by design it seems. You can sort
the list with it, but searching/adding will not work properly (or be
linear).
Why would you want to add/search while sorting?
After sorting, to search efficiently, why else ?
Micha
Michael Van Canneyt wrote:
The purpose of Customsearch is to sort the list once using a custom
sorting algorithm.
That reduces its usefulness, and why I said it's a broken design :).
Well, it fits with the rest of TStringList then :-)
Seriously, I wouldn't bother using TStringList. It's
Hi,
Does anyone use the CustomSort facility of TStringList ? I am a bit
troubled because it's broken by design it seems. You can sort the list
with it, but searching/adding will not work properly (or be linear). I
want to have a callback that gives you two strings to compare, instead
of two
15 matches
Mail list logo