Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Do nesting level
Message
 
 
À
17/09/2001 05:44:21
Jimi Lee
Pop Electronic Products Ltd.
Hong Kong, Hong Kong
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00557186
Message ID:
00557213
Vues:
25
Well, as you wish.
Custom algorithm over large number of object will work slowly, it cannot be more quick than a C++ routine in ASORT(). Also, there are only a few lines of code for this approach, when custom sorting algorithm is a lot of programming...

>Yeah though it will be much work to rewrite the program, I think I better do it asap.. thanks for the suggestions
>
>Jimi
>
>>Hi!
>>
>>Yep.
>>
>>MyObjects(i,2) = padl(val(m.cObjValue),4,"0")+substr(m.cObjValue,len(val(m.cObjValue))+1)
>>
>>This will make them all like
>>0001, 0002, 0002A, 0003, 0003A, 0003B, 0010, 0010A...etc.
>>
>>and in character comparison it will be "0002"<"0010".
>>
>>HTH.
>>
>>
>>>hi Vlad,
>>>
>>>i didn't use the asort() because I'm sorting something like:
>>>1, 2, 2A, 3, 3A, 3B, 10, 10A...etc.
>>>
>>>since 2A 3A are valid, I cannot use integer but strings, but at the same time 10 must be larger than 2 that for string comparsion foxpro would think 2 is larger... I dunno how to fix this so I used a custom sorting..
>>>
>>>any idea?
>>>
>>>Jimi
>>>
>>>>Hi!
>>>>
>>>>Any recursive function could be re-written to use a loop instead of recursive call.
>>>>
>>>>However, I'm wondered - WHY not use ASORT() function????????
>>>>dimension MyObjects(nObjectsCount,2)
>>>>for i=1 to nObjectsCount
>>>> MyObjects(i,1) = ... && some object reference
>>>> MyObjects(i,2) = ... && value used for comparison for sorting
>>>>endfor
>>>>
>>>>ASORT(MyObjects,2)
>>>>
>>>>And thats all.
>>>>This way should be MUCH more quick then just a custom sorting algorithm.
>>>>
>>>>HTH.
>>>>
>>>>Make array 2-dimensioned with 2 columns. One contains object reference. Another column contains value which you use for sorting. Then use ASORT(aArray,)
>>>>
>>>>>I have wrote a function to quick-sort' an array of objects, but when the array is a bit larger (~600), I receive an "Allowed DO nesting level exceeded." error message.
>>>>>
>>>>>I do not have any do-loop included in another do-loop, but maybe it still counted when a do-loop is included in my recursive function...
>>>>>
>>>>>Is it posible to remove this limitation, or must I rewrite my recursive function?
>>>>>
>>>>>Thanks,
>>>>>Jimi
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform