1 package antlr.collections.impl;
2
3
4 import antlr.collections.List;
5 import antlr.collections.Stack;
6 import java.util.Enumeration;
7 import java.util.NoSuchElementException;
8 import antlr.collections.impl.LLCell;
9
10 * bad things would happen if the list changed via another thread
12 * while we were walking this list.
13 */
14 final class LLEnumeration implements Enumeration {
15 LLCell cursor;
16 LList list;
17
18
19
20 public LLEnumeration(LList l) {list = l; cursor=list.head;}
21 * elements to enumerate.
23 */
24 public boolean hasMoreElements() {
25 if ( cursor!=null ) return true;
26 else return false;
27 }
28 * the returned element is removed from the enumeration. This
30 * does not affect the list itself.
31 * @return the next object in the enumeration.
32 */
33 public Object nextElement() {
34 if ( !hasMoreElements() ) throw new NoSuchElementException();
35 LLCell p = cursor;
36 cursor = cursor.next;
37 return p.data;
38 }
39 }
40