Back to index

wims  3.65+svn20090927
DepList.java
Go to the documentation of this file.
00001 package rene.zirkel.construction;
00002 
00003 // file: ConstructionObject.java
00004 
00005 import java.util.*;
00006 
00007 import rene.zirkel.objects.*;
00008 
00009 public class DepList implements Enumeration
00010 {      ConstructionObject E[]=new ConstructionObject[8];
00011        int N=0,I;
00012        public void reset () { N=0; }
00013        public void add (ConstructionObject o)
00014        {      if (have(o)) return;
00015               if (N<E.length) E[N++]=o;
00016               else
00017               {      ConstructionObject e[]=new ConstructionObject[E.length+8];
00018                      for (int i=0; i<E.length; i++) e[i]=E[i];
00019                      E=e;
00020                      E[N++]=o;
00021               }
00022        }
00023        public boolean have (ConstructionObject o)
00024        {      for (int i=0; i<N; i++)
00025                      if (E[i]==o) return true;
00026               return false;
00027        }
00028        public Enumeration elements ()
00029        {      I=0; return this;
00030        }
00031        public boolean hasMoreElements () { return I<N; }
00032        public Object nextElement () { return E[I++]; }
00033        public ConstructionObject[] getArray ()
00034        {      ConstructionObject o[]=new ConstructionObject[N];
00035               for (int i=0; i<N; i++) o[i]=E[i];
00036               return o;
00037        }
00038        public void translate ()
00039        {      for (int i=0; i<N; i++)
00040                      E[i]=E[i].getTranslation();
00041        }
00042        public int size() { return N; }
00043 }