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