> 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
- RE: [DUG]: VB Like Case statement Jeremy Coulter
- Re: [DUG]: VB Like Case statement Neven MacEwan
- Re: [DUG]: VB Like Case statement Aaron Scott-Boddendijk
- RE: [DUG]: VB Like Case statement Dennis Chuah
- RE: [DUG]: VB Like Case statement Dennis Chuah
- RE: [DUG]: VB Like Case statement Dennis Chuah
- Re: [DUG]: VB Like Case statement Matt Powell
- Re: [DUG]: VB Like Case statement Aaron Scott-Boddendijk
- RE: [DUG]: VB Like Case statement Dennis Chuah
- Re: [DUG]: VB Like Case statement Aaron Scott-Boddendijk
- RE: [DUG]: VB Like Case statement Dennis Chuah
- RE: [DUG]: VB Like Case statement McKenzie, Paul
- Re: [DUG]: VB Like Case statement Aaron Scott-Boddendijk
- Re: [DUG]: VB Like Case statement Aaron Scott-Boddendijk
- RE: [DUG]: VB Like Case statement Grant Black
- Re: [DUG]: VB Like Case statement Nic Wise
- Re: [DUG]: VB Like Case statement Aaron Scott-Boddendijk
- RE: [DUG]: VB Like Case statement David O'Brien
- RE: [DUG]: VB Like Case statement Carl Reynolds
- RE: [DUG]: VB Like Case statement Carl Reynolds
- RE: [DUG]: VB Like Case statement Stacey Verner
