01: // Copyright (c) 2000, 2002 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.mapping;
05:
06: public class LocationEnumeration implements
07: /* #ifdef JAVA2 */
08: java.util.Iterator,
09: /* #endif */
10: java.util.Enumeration {
11: Environment env;
12: NamedLocation curLoc;
13: /** Index field used by Environment.hasMoreElements.
14: If inherited==null, index in bindings, else index in env.inherited. */
15: int index;
16: LocationEnumeration inherited;
17: NamedLocation[] bindings;
18:
19: public LocationEnumeration(NamedLocation[] bindings, int count) {
20: this .bindings = bindings;
21: index = count;
22: }
23:
24: public LocationEnumeration(SimpleEnvironment env) {
25: this (env.table, 1 << env.log2Size);
26: }
27:
28: public boolean hasMoreElements() {
29: return env.hasMoreElements(this );
30: }
31:
32: public Object nextElement() {
33: return nextLocation();
34: }
35:
36: public Location nextLocation() {
37: if (curLoc == null && !hasMoreElements())
38: throw new java.util.NoSuchElementException();
39: Location r = curLoc;
40: curLoc = curLoc.next;
41: return r;
42: }
43:
44: public boolean hasNext() {
45: return hasMoreElements();
46: }
47:
48: public Object next() {
49: return nextElement();
50: }
51:
52: public void remove() {
53: throw new Error(); // FIXME
54: //env.remove(loc);
55: }
56: }
|