KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > mapping > LocationEnumeration


1 // Copyright (c) 2000, 2002 Per M.A. Bothner.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.mapping;
5
6 public class LocationEnumeration
7   implements
8   /* #ifdef JAVA2 */
9   java.util.Iterator JavaDoc,
10   /* #endif */
11   java.util.Enumeration JavaDoc
12 {
13   Environment env;
14   NamedLocation curLoc;
15   /** Index field used by Environment.hasMoreElements.
16       If inherited==null, index in bindings, else index in env.inherited. */

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 JavaDoc nextElement()
38   {
39     return nextLocation();
40   }
41
42   public Location nextLocation()
43   {
44     if (curLoc == null && ! hasMoreElements())
45       throw new java.util.NoSuchElementException JavaDoc();
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 JavaDoc next ()
57   {
58     return nextElement();
59   }
60
61   public void remove ()
62   {
63     throw new Error JavaDoc(); // FIXME
64
//env.remove(loc);
65
}
66 }
67
Popular Tags