MSortedCollectionNode.java
Go to the documentation of this file.
00001 /*
00002  * (c) copyright 2008, Technische Universitaet Graz and Technische Universitaet Wien
00003  *
00004  * This file is part of jdiagengine.
00005  *
00006  * jdiagengine is free software: you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation, either version 3 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * jdiagengine is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * You should have received a copy of the GNU General Public License
00016  * along with jdiagengine. If not, see <http://www.gnu.org/licenses/>.
00017  *
00018  * Authors: Joerg Weber, Franz Wotawa
00019  * Contact: jweber@ist.tugraz.at (preferred), or fwotawa@ist.tugraz.at
00020  *
00021  */
00022 
00023 
00024 package utils;
00025 
00026 import java.util.*;
00027 
00028 public class MSortedCollectionNode extends Object
00029 {
00030     protected MSortedCollectionNode left;
00031     protected MSortedCollectionNode right;
00032     protected MSortedElementInterface object;
00033 
00034     public MSortedCollectionNode () {
00035         left = null;
00036         right = null;
00037         object = null;
00038     }
00039 
00040     public void left(MSortedCollectionNode node) {
00041         left = node;
00042     }
00043 
00044     public void right(MSortedCollectionNode node) {
00045         right = node;
00046     }
00047 
00048     public void addElement(MSortedElementInterface obj) {
00049         if (object == null) {
00050             object = obj;
00051             left = new MSortedCollectionNode();
00052             right = new MSortedCollectionNode();
00053         } else {
00054             if (object.greater(obj)) {
00055                 left.addElement(obj);
00056             } else {
00057                 right.addElement(obj);
00058             }
00059         }
00060     }
00061 
00062     public ArrayList allElements() {
00063         ArrayList v = new ArrayList();
00064         if (object != null) {
00065             return this.allElements(v);
00066         } else {
00067             return v;
00068         }
00069     }
00070 
00071     public ArrayList allElements(ArrayList v) {
00072         if (object != null) {
00073             left.allElements(v);
00074             v.add(object);
00075             right.allElements(v);
00076         }
00077         return v;
00078     }
00079 
00080     public ArrayList allElementsInverse() {
00081         ArrayList v = new ArrayList();
00082         if (object != null) {
00083             return this.allElementsInverse(v);
00084         } else {
00085             return v;
00086         }
00087     }
00088 
00089     public ArrayList allElementsInverse(ArrayList v) {
00090         if (object != null) {
00091             right.allElementsInverse(v);
00092             v.add(object);
00093             left.allElementsInverse(v);
00094         }
00095         return v;
00096     }
00097 
00098 }


tug_ist_diagnosis_engine
Author(s): Safdar Zaman, Gerald Steinbauer
autogenerated on Mon Jan 6 2014 11:51:16