1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| FILL_LIST( p_List As t_Ptr_Dico, Chain As String, ByRef Nb_Cells As Integer, Posit As Integer )
Dim p_Inser As t_Ptr_Dico // Pointe vers l'élément à insérer dans l'arbre.
If Posit <= Len(Chain) Then // S'il reste des caractères à ajouter, alors
If p_List = Nil OR p_List.Char > Mid( Chain, Posit, 1 ) Then // S'il faut ajouter au début
CREATION_CELL( p_Inser, Mid( Chain, Posit, 1) ) // Création & initialisation de la cellule
Nb_Cells = Nb_Cells + 1 // On ajoute 1 au nombre de cellules
p_Inser.Other = p_List // Chaînage
p_List = p_Inser
FILL_LIST( p_List.Next, Chain, Nb_Cells, Posit + 1 )
// Ajout dans le sous-arbre du bas.
else // Si on n'ajoute pas au début.
if p_List.Char = Mid( Chain, Posit, 1 ) Then // Si le caractère est déjà présent à ce niveau, alors
FILL_LIST( p_List.Next, Chain, Nb_Cells, Posit + 1 ) // Ajouter dans le sous-arbre du bas.
else // Sinon, le caractère n'est pas présent à ce niveau.
FILL_LIST( p_Liste.Other, Chain, Nb_Cells, Posit ) // Ajout dans le sous-arbre droit.
end if
end if
end if
Avec t_Ptr_Dico (Char As String, Next As t_Ptr_Dico, Other As t_Ptr_Dico) |
Partager