01: package antlr.collections.impl;
02:
03: /* ANTLR Translator Generator
04: * Project led by Terence Parr at http://www.cs.usfca.edu
05: * Software rights: http://www.antlr.org/license.html
06: */
07:
08: import java.util.Enumeration;
09: import java.util.NoSuchElementException;
10:
11: import antlr.collections.Enumerator;
12:
13: // based on java.lang.Vector; returns any null indices between non-null ones.
14:
15: class VectorEnumerator implements Enumeration {
16: Vector vector;
17: int i;
18:
19: VectorEnumerator(Vector v) {
20: vector = v;
21: i = 0;
22: }
23:
24: public boolean hasMoreElements() {
25: synchronized (vector) {
26: return i <= vector.lastElement;
27: }
28: }
29:
30: public Object nextElement() {
31: synchronized (vector) {
32: if (i <= vector.lastElement) {
33: return vector.data[i++];
34: }
35: throw new NoSuchElementException("VectorEnumerator");
36: }
37: }
38: }
|