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 00038 public class MSortedCollection extends Object { 00039 00040 protected int elementCount = 0; 00041 protected MSortedCollectionNode topNode = null; 00042 00046 public MSortedCollection() { 00047 topNode = new MSortedCollectionNode(); 00048 } 00049 00053 public void addElement(MSortedElementInterface element) { 00054 elementCount = elementCount + 1; 00055 topNode.addElement(element); 00056 } 00057 00061 public void addAllElements(ArrayList v) { 00062 Iterator e = v.iterator(); 00063 while (e.hasNext()) { 00064 addElement((MSortedElementInterface)e.next()); 00065 } 00066 } 00067 00068 00072 public void removeElement(MSortedElementInterface element) { 00073 } 00074 00077 public void removeAllElements() { 00078 elementCount = 0; 00079 topNode = new MSortedCollectionNode(); 00080 } 00081 00085 public int size() { 00086 return elementCount; 00087 } 00088 00092 public Iterator elements() { 00093 return (topNode.allElements()).iterator(); 00094 } 00095 00096 public ArrayList elementsVector() { 00097 return topNode.allElements(); 00098 } 00099 00104 public Iterator elementsInverse() { 00105 return (topNode.allElementsInverse()).iterator(); 00106 } 00107 00108 public ArrayList elementsVectorInverse() { 00109 return topNode.allElementsInverse(); 00110 } 00111 00112 } 00113 00114 00115 00116 00117 00118 00119 00120 00121