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 antlr.collections.impl.Vector;
09: import antlr.collections.ASTEnumeration;
10: import antlr.collections.AST;
11:
12: import java.util.NoSuchElementException;
13:
14: public class ASTEnumerator implements antlr.collections.ASTEnumeration {
15: /** The list of root nodes for subtrees that match */
16: VectorEnumerator nodes;
17: int i = 0;
18:
19: public ASTEnumerator(Vector v) {
20: nodes = new VectorEnumerator(v);
21: }
22:
23: public boolean hasMoreNodes() {
24: synchronized (nodes) {
25: return i <= nodes.vector.lastElement;
26: }
27: }
28:
29: public antlr.collections.AST nextNode() {
30: synchronized (nodes) {
31: if (i <= nodes.vector.lastElement) {
32: return (AST) nodes.vector.data[i++];
33: }
34: throw new NoSuchElementException("ASTEnumerator");
35: }
36: }
37: }
|