1 package antlr.collections.impl; 2 3 9 10 import java.util.Enumeration ; 11 import java.util.NoSuchElementException ; 12 13 import antlr.collections.Enumerator; 14 15 17 class VectorEnumerator implements Enumeration { 18 Vector vector; 19 int i; 20 21 22 VectorEnumerator(Vector v) { 23 vector = v; 24 i = 0; 25 } 26 27 public boolean hasMoreElements() { 28 synchronized (vector) { 29 return i <= vector.lastElement; 30 } 31 } 32 33 public Object nextElement() { 34 synchronized (vector) { 35 if (i <= vector.lastElement) { 36 return vector.data[i++]; 37 } 38 throw new NoSuchElementException ("VectorEnumerator"); 39 } 40 } 41 } 42 | Popular Tags |