import java.util.Iterator; import arbre.Arbre; import arbre.Fonction; import arbre.ModificationInterditeException; /* * Created on 15 nov. 2004 * */ /** * @author baudon * */ public class Test { public static void main(String[] args) throws Exception { Arbre a = new Arbre(new Arbre(new Arbre(null, null, "1"), new Arbre(null, null, "2"), "3"), new Arbre(null, null, "4"), "5"); for (Iterator it = a.iteration(); it.hasNext();) { System.out.print(it.next() + " "); } System.out.println(); final StringBuffer s = new StringBuffer(); a.appliquer(new Fonction() { public boolean f(String o) { s.append(o + " "); return !o.equals("3"); } }); System.out.println(s); Iterator it1 = a.iteration(); Iterator it2 = a.iteration(); while (it1.hasNext() && it2.hasNext()) { System.out.print(it1.next()); try { a.elaguerDroit(); } catch (ModificationInterditeException e) { System.out.println(" " + e.nIterateursEnCours() + " iterateurs en cours"); } System.out.print(it2.next()); try { a.elaguerDroit(); } catch (ModificationInterditeException e) { System.out.println(" " + e.nIterateursEnCours() + " iterateurs en cours"); } } System.out.println(); for (Iterator it = a.iteration(); it.hasNext();) { System.out.print(it.next() + " "); } System.out.println(); } }