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