KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > prefuse > util > collections > IntArrayIterator


1 /**
2  * Copyright (c) 2004-2006 Regents of the University of California.
3  * See "license-prefuse.txt" for licensing terms.
4  */

5 package prefuse.util.collections;
6
7 import java.util.NoSuchElementException JavaDoc;
8
9 /**
10  * IntIterator implementation that provides an iteration over the
11  * contents of an int array.
12  *
13  * @author <a HREF="http://jheer.org">jeffrey heer</a>
14  */

15 public class IntArrayIterator extends IntIterator {
16
17     private int[] m_array;
18     private int m_cur;
19     private int m_end;
20     
21     public IntArrayIterator(int[] array, int start, int len) {
22         m_array = array;
23         m_cur = start;
24         m_end = start+len;
25     }
26     
27     /**
28      * @see prefuse.util.collections.IntIterator#nextInt()
29      */

30     public int nextInt() {
31         if ( m_cur >= m_end )
32             throw new NoSuchElementException JavaDoc();
33         return m_array[m_cur++];
34     }
35
36     /**
37      * @see java.util.Iterator#hasNext()
38      */

39     public boolean hasNext() {
40         return m_cur < m_end;
41     }
42     
43     public void remove() {
44         throw new UnsupportedOperationException JavaDoc();
45     }
46
47 } // end of class IntArrayIterator
48
Popular Tags