Advertisement
parseint32

dll nodi visite

Apr 26th, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace AlberiBinari
  7. {
  8.     public class Nodo
  9.     {
  10.         public Nodo Sx { get; set; }
  11.         public Nodo Dx { get; set; }
  12.         public object Contenuto { get; set; }
  13.         public Nodo(object c)
  14.         {
  15.             Contenuto = c;
  16.         }
  17.     }
  18.  
  19.     public class Visita
  20.     {
  21.         public event Action<Nodo> OnVisit;
  22.         public void VisitaAnticipata(Nodo Root)
  23.         {
  24.             if (Root != null)
  25.             {
  26.                 if (OnVisit != null) OnVisit(Root);
  27.             }
  28.            
  29.             if (Root.Sx != null)
  30.                 VisitaAnticipata(Root.Sx);
  31.  
  32.             if (Root.Dx != null)
  33.                 VisitaAnticipata(Root.Dx);
  34.         }
  35.  
  36.         public  void VisitaSimmetrica(Nodo Root)
  37.         {            
  38.             if (Root.Sx != null)
  39.                 VisitaSimmetrica(Root.Sx);
  40.  
  41.             if (Root != null)
  42.                 if (OnVisit != null) OnVisit(Root);
  43.  
  44.             if (Root.Dx != null)
  45.                 VisitaSimmetrica(Root.Dx);
  46.         }
  47.  
  48.         public void VisitaDifferita(Nodo Root)
  49.         {
  50.             if (Root.Sx != null)
  51.                 VisitaDifferita(Root.Sx);            
  52.  
  53.             if (Root.Dx != null)
  54.                 VisitaDifferita(Root.Dx);
  55.  
  56.             if (Root != null)
  57.                 if (OnVisit != null) OnVisit(Root);
  58.         }      
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement