01: /**
02: * Copyright (c) 2004-2006 Regents of the University of California.
03: * See "license-prefuse.txt" for licensing terms.
04: */package prefuse.util.collections;
05:
06: import java.util.NoSuchElementException;
07:
08: /**
09: * IntIterator implementation that provides an iteration over the
10: * contents of an int array.
11: *
12: * @author <a href="http://jheer.org">jeffrey heer</a>
13: */
14: public class IntArrayIterator extends IntIterator {
15:
16: private int[] m_array;
17: private int m_cur;
18: private int m_end;
19:
20: public IntArrayIterator(int[] array, int start, int len) {
21: m_array = array;
22: m_cur = start;
23: m_end = start + len;
24: }
25:
26: /**
27: * @see prefuse.util.collections.IntIterator#nextInt()
28: */
29: public int nextInt() {
30: if (m_cur >= m_end)
31: throw new NoSuchElementException();
32: return m_array[m_cur++];
33: }
34:
35: /**
36: * @see java.util.Iterator#hasNext()
37: */
38: public boolean hasNext() {
39: return m_cur < m_end;
40: }
41:
42: public void remove() {
43: throw new UnsupportedOperationException();
44: }
45:
46: } // end of class IntArrayIterator
|