jstrachan    01/08/23 02:05:26

  Modified:    collections/src/java/org/apache/commons/collections
                        ArrayIterator.java
  Log:
  Patched ArrayIterator so that it can work with any type of array, not just Object[] 
instances
  
  Revision  Changes    Path
  1.4       +8 -7      
jakarta-commons/collections/src/java/org/apache/commons/collections/ArrayIterator.java
  
  Index: ArrayIterator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/ArrayIterator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ArrayIterator.java        2001/06/05 07:20:06     1.3
  +++ ArrayIterator.java        2001/08/23 09:05:26     1.4
  @@ -7,6 +7,7 @@
    */
   package org.apache.commons.collections;
   
  +import java.lang.reflect.Array;
   import java.util.Iterator;
   import java.util.NoSuchElementException;
   
  @@ -15,32 +16,32 @@
     * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
     * @author Mauricio S. Moura
     * @
  -  * @version $Revision: 1.3 $
  +  * @version $Revision: 1.4 $
     */
   public class ArrayIterator implements Iterator {
       
  -    private Object[] array;
  +    private Object array;
       private int index = 0;
     
       
       public ArrayIterator() {
       }
       
  -    public ArrayIterator(Object[] array) {
  +    public ArrayIterator(Object array) {
           this.array = array;
       }
   
       // Iterator interface
       //-------------------------------------------------------------------------
       public boolean hasNext() {
  -        return  (index < array.length);
  +        return  index < Array.getLength( array );
       }
   
       public Object next() {
           if(!hasNext()) {
               throw new NoSuchElementException();
           }
  -        return array[ index++ ];
  +        return Array.get( array, index++ );
       }
   
       public void remove() {
  @@ -49,11 +50,11 @@
   
       // Properties
       //-------------------------------------------------------------------------
  -    public Object[] getArray() {
  +    public Object getArray() {
           return array;
       }
       
  -    public void setArray( Object[] array ) {
  +    public void setArray( Object array ) {
           this.array = array;
           this.index = -1;
       }
  
  
  

Reply via email to