1 11 package org.eclipse.core.internal.utils; 12 13 import java.util.Iterator ; 14 import java.util.NoSuchElementException ; 15 16 19 public class ArrayIterator implements Iterator { 20 Object [] elements; 21 int index; 22 int lastElement; 23 24 27 public ArrayIterator(Object [] elements) { 28 this(elements, 0, elements.length - 1); 29 } 30 31 34 public ArrayIterator(Object [] elements, int firstElement, int lastElement) { 35 super(); 36 this.elements = elements; 37 index = firstElement; 38 this.lastElement = lastElement; 39 } 40 41 44 public boolean hasNext() { 45 return elements != null && index <= lastElement; 46 } 47 48 52 public Object next() throws NoSuchElementException { 53 if (!hasNext()) 54 throw new NoSuchElementException (); 55 return elements[index++]; 56 } 57 58 public void remove() { 59 throw new UnsupportedOperationException (); 60 } 61 } 62 | Popular Tags |