[fpc-devel] Re: enumerators

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sun Nov 14 22:12:02 CET 2010

Vincent Snijders schrieb:
> 2010/11/14 Thaddy <thaddy at thaddy.com>:
>> On 13-11-2010 20:56, Hans-Peter Diettrich wrote:
>>> The comparison in the UTF-8 string example is very questionable. First
>>> ch(i) is not equivalent to ch, not even closely related, and the claim of
>>> O(N^2) operations deserves an proof - IMO it's simply wrong.
>> Yes, this caught my eye as well: O(N^2) seems only the case if "length"
>> would be evaluated every time. S
> the O(N^2) stems from the fact that it is hard to get the ith
> character in a a UTF8String in O(1). Suppose it is o(N), then the loop
> is O(n^2).

With regards to UTF-8 (or other MBCS) strings, what does Length(s) 
return in these cases? IMO other functions have to be used for the 
determination of the true character count (as opposed to the char=byte 

At least the example code has to be made work, i.e. the nonsense statement
has to be changed into something like
before we can can talk honestly about the order of the loop.


More information about the fpc-devel mailing list