> the Stringlist example I gave could have used Sorted := True.
> Use of the IndexOf
> method is still correct as IndexOf checks if the list is
> sorted and uses find when
> it is... The sorting process may be less-efficient than
> simply using the iterative
> search on the unsorted list... Sorting takes nlog(n)
> comparisons for Quicksort I
> believe.
>
> The Find parameters in the above are incorrect and I didn't
> see any suggestion
> in the original question than an associated object was
> available for each string.
>
> with TStringList.Create do try
> commatext := 'hello,goodbye';
> Sorted := True; // This may actually slow down the performance.
Of course - you sort it ONCE and cache the stringlist - afterall, it is
constant!
> case IndexOf(MyVar) of
> 0: Show_Hello;
> 1: Show_Goodbye;
> end;
> finally
> Free;
> end;
This won't actually work because the sorting changes the order of the items.
Dennis.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz