Created
March 17, 2010 03:39
-
-
Save damog/334877 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class ArrayIterator<E> implements Iterator<E> { | |
private final E[] array; | |
private final int count; | |
private int cursor = 0; | |
public ArrayIterator(E[] contents, int ccount) { | |
array = contents; | |
count = ccount; | |
} | |
public boolean hasNext() { | |
if( cursor == count ) { | |
return false; | |
} else { | |
return true; | |
} | |
} | |
public E next() { | |
E sig = array[cursor]; | |
cursor++; | |
return sig; | |
} | |
public void remove() throws UnsupportedOperationException {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment