1 4 package gnu.mapping; 5 6 public class LocationEnumeration 7 implements 8 9 java.util.Iterator , 10 11 java.util.Enumeration 12 { 13 Environment env; 14 NamedLocation curLoc; 15 17 int index; 18 LocationEnumeration inherited; 19 NamedLocation[] bindings; 20 21 public LocationEnumeration(NamedLocation[] bindings, int count) 22 { 23 this.bindings = bindings; 24 index = count; 25 } 26 27 public LocationEnumeration(SimpleEnvironment env) 28 { 29 this(env.table, 1 << env.log2Size); 30 } 31 32 public boolean hasMoreElements() 33 { 34 return env.hasMoreElements(this); 35 } 36 37 public Object nextElement() 38 { 39 return nextLocation(); 40 } 41 42 public Location nextLocation() 43 { 44 if (curLoc == null && ! hasMoreElements()) 45 throw new java.util.NoSuchElementException (); 46 Location r = curLoc; 47 curLoc = curLoc.next; 48 return r; 49 } 50 51 public boolean hasNext () 52 { 53 return hasMoreElements(); 54 } 55 56 public Object next () 57 { 58 return nextElement(); 59 } 60 61 public void remove () 62 { 63 throw new Error (); } 66 } 67 | Popular Tags |