Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CHRTRAN and remove characters
Message
From
14/10/2004 06:26:48
 
 
To
14/10/2004 06:14:33
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Beta
Miscellaneous
Thread ID:
00950654
Message ID:
00951319
Views:
8
Don't think we do

We all know that moving a char once is the best

Fabio said in message#950945

>A simple optimization is that of do the substituytion right to left,
>this is not the best possible, but it can reduce the k on O(k*n*n).

David responded
>That is no optimization at all it still ends up moving the exact same number of bytes as doing it left to right.

Arguement of Fabio : (simple)Right to left moves less chars than (simple) left to right

___________________________________________

>Fabio and Gregory,
>
>I think you miss the point of david here. His algortithm is only moving the characters that are in the result and they're moved only once. His algorithm is (more or less) equivalent to the following VFP code
>
>
FUNCTION DeQoute (cString)
>LOCAL nPointer
>
>nPointer = 0
>FOR nT = 1 TO LEN(cString)
>    cChar = SUBSTR(cString, nT, 1)
>    IF cChar != '"'
>        nPointer = nPointer + 1
>        cString = STUFF(cString, nPointer, 1, cChar)
>    ENDIF
>ENDFOR
>
>cString = SUBSTR(cString,1, nPointer)
>RETURN LEN(cString)
>
>Each character is only handled once. Honestly I really don't see any advantage to approach this problem from a right to left strategy here.
>
>The difference with the current implementation of CHRTRAN is that when a iterating through the characters in the string, it is going to move all remaining characters 1 position back whenever a character needs to be deleted. This results in the performance issue posibly a huge number of characters have moved multiple times in one CHARTRAN call. This is certainly not the case in davids algorithm.
>
>Walter,
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform