Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need INDEX long string.
Message
De
28/05/2003 15:41:45
 
 
À
28/05/2003 12:16:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00793472
Message ID:
00793693
Vues:
21
>Thanks Gregory,
>
>but my schema is for remove need to recursive calls.
>
>VFP support only 128 recursive calls, and MSQL only 32 calls.
>
>I want no limit to levels.
>
>I need index memo binary fields.
>
>Fabio

Fabio,

I believe even the index on 254 or so chars will limit the levels anyway

No recursive calls, I see

The following piece of code is a method to do that. No node is visited twice, in case a node would have multiple parents.
If a node cannot have multiple parents
     take out the Closed stuff in the code below.  That will limit the levels to 65000
     you can of course hold the Open list in a cursor, then no limits to the # of levels
else
     leave the closed stuff
     that will limit the # of nodes to 65000 (in Closed)
     unless you put the closed list in a cursor, no 65000 # of nodes limit, but slower
endif
Here's the algorithm (I have not tested it.)
&&Unexplored nodes are put on an Open list
Put the start node in the Open list
do while there are nodes in Open
    An action is done on a node in Open
    The node in Open is moved to the Closed list
    That node is expanded
    for each successor
      if not in Closed list
         add to the Open list
      endif
    endfor
enddo
*---------------------------------------------------------------------------
function do_it()

	create cursor Tree ;
	(	Parent I default 0, ;
		Child  I default 0 ;
	)
	select Tree
	Index on bintoc(Parent) tag Parent  && optional
	index on bintoc(Child) tag Child  && optional

	index on  bintoc(Parent) + bintoc(-Child) tag Down  && yes: -Child
*---------------------------------------------------------------------------
#define NODES_MAX	65000

Function Traverse(StartNode)  && depth first

	local ParentCurrent
	
	local Nodes_Closed[ NODES_MAX ], Nodes_Open[ NODES_MAX ]
	
	local nOpen, nClosed
	nOpen = 0
	nClosed = 0
	
	&& put the startnode in open
	
	=seek(bintoc(StartNode)) 
	if( Parent == StartNode )
		nOpen = nOpen + 1
		Nodes_Open[ nOpen ] = recno()
	endif
		
    do while !empty(nOpen)
    
    	go (Nodes_Open[ nOpen ] )
    	
    	&& take the node from Open
    	Nodes_Open[ nOpen ] = Null  && optional
    	nOpen = nOpen - 1
    	
    	&& and put it in  Closed
    	nClosed = nClosed + 1
    	Nodes_Closed[ nClosed ] = recno()
    	
    	&& put the action for the node here
    	
    	&& traverse
    	ParentCurrent = Parent
    	scan rest while ( Parent == ParentCurrent )
    		
    		&& if the node in not in Closed
    		do case
    		case empty( ascan( Nodes_Closed, recno()) )
    			&& add it to Open
    			nOpen = nOpen + 1
    			Nodes_Open[ nOpen ] = recno()
    		
    		endcase
    	endscan
    
    enddo
endfunc
*---------------------------------------------------------------------------
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform