Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void conflict() {
- //Si j'ai aucun fils, alors je quitte la fonction.
- if (emptyL() && emptyR())
- return;
- //Si j'ai aucun petit-fils.
- if (!emptyL() && !emptyR() && getL().emptyL() && getL().emptyR() && getR().emptyL() && getR().emptyR())
- return;
- //Si l'élément courant est noir.
- if (isBlk()){
- //Et si j'ai un fils gauche.
- if (!emptyL()){
- //Si ce fiche gauche est rouge.
- if (getL().isRed()){
- //Je test si mon petit fils "gauche"-"gauche" existe.
- if (getL().getL().!emptyL()){
- //Si mon petit-fils "gauche"-"gauche" est rouge.
- //Alors je réarange l'arbre.
- if (getL().getL().isRed()){
- //TREATMENT
- }
- else
- getL().getL().conflict();
- }
- else if (getL().getR().!emptyR()){
- if(getL().getR().isRed()){
- //TREATMENT
- }
- else
- getL().getR().conflict();
- }
- }
- else
- getL().conflict();
- }
- if (!emptyR()){
- if (getR().isRed()){
- if (getR().getR().!emptyR()){
- if (getR().getR().isRed()){
- //TREATMENT
- }
- else
- getR().getR().conflict();
- }
- else if (getR().getL().!emptyL()){
- if(getR().getL().isRed()){
- //TREATMENT
- }
- else
- getR().getL().conflict();
- }
- }
- else
- getR().conflict();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement