KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > uk > co > jezuk > mango > iterators > ArrayIterator


1 package uk.co.jezuk.mango.iterators;
2
3 /**
4  * Iterators over an object array, allowing to be treated in a similar
5  * way to a collection.
6  *
7  * @author Jez Higgins, jez@jezuk.co.uk
8  * @version $Id: ArrayIterator.java 65 2002-07-31 21:59:26Z jez $
9  */

10 public class ArrayIterator implements java.util.Iterator JavaDoc
11 {
12   public ArrayIterator(Object JavaDoc[] array)
13   {
14     array_ = array;
15     index_ = 0;
16   } // ArrayIterator
17

18   public boolean hasNext()
19   {
20     return (array_ != null) && (index_ != array_.length);
21   } // hasNext
22

23   public Object JavaDoc next()
24   {
25     return array_[index_++];
26   } // next
27

28   public void remove()
29   {
30     throw new UnsupportedOperationException JavaDoc("uk.co.jezuk.mango.ArrayIterator does not support the remove method");
31   } // remove
32

33   //////////////////////
34
private Object JavaDoc[] array_;
35   private int index_;
36 } // ArrayIterator
37
Popular Tags