public void Ajouter(T content) { if (this.content.isInferieur(content)) { if (this.filsGauche == null) { this.filsGauche = new ElementArbreBinaire <T>(content); } else { this.filsGauche.Ajouter(content); } } else { if (this.filsDroit == null) { this.filsDroit = new ElementArbreBinaire <T>(content); } else { this.filsDroit.Ajouter(content); } } }
public void Ajouter(T content) { if (this.racine != null) { this.racine.Ajouter(content); } else { this.racine = new ElementArbreBinaire <T>(content); } }
public override string ToString() { string printedString = ""; int currentEtage = 0; if (this.racine != null) { //var population = new Tuple<int, string>(1, "7891957"); File <Tuple <int, ElementArbreBinaire <T> > > file = new File <Tuple <int, ElementArbreBinaire <T> > >(255); printedString += this.racine.getContent().ToString() + '\n'; file.Ajouter(new Tuple <int, ElementArbreBinaire <T> >(0, this.racine)); while (!file.isVide()) { Tuple <int, ElementArbreBinaire <T> > tuple = file.Extraire().getContent(); ElementArbreBinaire <T> currentElementArbre = tuple.Item2; if (currentEtage != tuple.Item1) { currentEtage++; printedString += '\n'; } if (currentElementArbre.getFilsGauche() != null) { file.Ajouter(new Tuple <int, ElementArbreBinaire <T> >(tuple.Item1 + 1, currentElementArbre.getFilsGauche())); printedString += currentElementArbre.getFilsGauche().getContent().ToString() + ""; } if (currentElementArbre.getFilsDroit() != null) { file.Ajouter(new Tuple <int, ElementArbreBinaire <T> >(tuple.Item1 + 1, currentElementArbre.getFilsDroit())); printedString += currentElementArbre.getFilsDroit().getContent().ToString() + " "; } } } return(printedString); }
public ElementArbreBinaire(T content, ElementArbreBinaire <T> filsDroit = null, ElementArbreBinaire <T> filsGauche = null) { this.filsDroit = filsDroit; this.filsGauche = filsGauche; this.content = content; }