Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CHRTRAN and remove characters
Message
From
14/10/2004 07:15:16
 
 
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:
00951329
Views:
6
>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,


Hi Walter,
as Gregory has said, I have not never made reference the algorithm of David.

Moreover, the algorithm of David is not the best possible one in the case of CHRTRAN().
When the LEN(param2)=LEN(param3) never copy it is necessary ( a single pointer is sufficient ).
And CHRTRAN is similar to a ASCAN/LOOKUP/SELECT JOIN, and therefore in some cases
( when the second string is long)
it could be useful to use one Hashing technical,
similar to the SYS(15) command.

Fabio
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform