Pagina 2 di 2 primaprima 1 2
Visualizzazione dei risultati da 11 a 15 su 15
  1. #11
    Utente di HTML.it L'avatar di evil80
    Registrato dal
    May 2001
    Messaggi
    321
    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

  2. #12
    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

  3. #13

    Node.cls

    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

  4. #14

    BinTree.cls

    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

  5. #15

    mainFrm.frm

    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

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.