scusa non capisco,hai usato un oggetto dictionary ?
Come hai fatto ?
Che metodi o proprietà hai impostato per l'oggetto ?
Fammi sapere al + presto grazie 1000 !
![]()
scusa non capisco,hai usato un oggetto dictionary ?
Come hai fatto ?
Che metodi o proprietà hai impostato per l'oggetto ?
Fammi sapere al + presto grazie 1000 !
![]()
Secondo alcuni autorevoli testi di tecnica di aeronautica, il calabrone non può volare, a causa della forma e del peso del proprio corpo in rapporto alla superficie alare.
Ma il calabrone non lo sa e perciò continua a volare.
Igor Sikorsky
No, ho implementato un rudimentale albero binario in VB.
Se però il file di input è già in ordine alfabetico non risulta molto più veloce di un normale oggetto dictionary o di un oggetto Collection.
Ti posto il codice così vedi un po' tu se puo' servirti
codice:Option Explicit Public val As String Public left As Node Public right As Node Public Function Add(s As String) As Boolean Add = False If s > val Then If right Is Nothing Then Add = True Set right = New Node right.val = s Else Add = right.Add(s) End If ElseIf s < val Then If left Is Nothing Then Add = True Set left = New Node left.val = s Else Add = left.Add(s) End If End If End Function
codice:Option Explicit Public Event nextNode(s As String) Private root As Node Private m_count As Long Private current As Node Private first As Node Public Sub traverse_rand() traverse_rand2 root End Sub Private Sub traverse_rand2(n As Node) If n Is Nothing Then Exit Sub 'restituisce i dati a casaccio così non si sbilancia troppo l'albero 'nella successiva lettura del file Dim a As Long a = Int((6 - 2) * Rnd + 1) Select Case a Case 1 traverse2 n.left RaiseEvent nextNode(n.val) traverse2 n.right Case 2 RaiseEvent nextNode(n.val) traverse2 n.left traverse2 n.right Case 3 traverse2 n.left traverse2 n.right RaiseEvent nextNode(n.val) Case 4 traverse2 n.right RaiseEvent nextNode(n.val) traverse2 n.left Case 5 RaiseEvent nextNode(n.val) traverse2 n.right traverse2 n.left Case 6 traverse2 n.right traverse2 n.left RaiseEvent nextNode(n.val) End Select End Sub Public Sub Add(s As String) If root Is Nothing Then Set root = New Node root.val = s Exit Sub End If root.Add s End Sub
codice:Option Explicit Dim WithEvents d As BinTree Dim P As String Dim fd As Integer Private Sub LevaDuplicati_click() Dim a, b Set d = New BinTree Dim dt As Double dt = CDbl(Now()) fd = FreeFile() Open "c:\prova.txt" For Binary As fd Dim s As String s = String(LOF(fd), Chr(0)) Get #fd, , s Close #fd a = Split(s, vbCrLf) s = "" 'On Error Resume Next For Each b In a d.Add CStr(b) Next fd = FreeFile() Open "c:\log.txt" For Output As #fd d.traverse_rand Close #fd Debug.Print CDbl(Now() - dt) End Sub Private Sub d_nextNode(s As String) Print #fd, s End Sub