Backed out ArrayIterator change to use reflection rather than use Object[]

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130496 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2001-08-23 10:50:01 +00:00
parent ea64efd6dc
commit 530049b41c
2 changed files with 12 additions and 13 deletions

View File

@ -7,7 +7,6 @@
*/
package org.apache.commons.collections;
import java.lang.reflect.Array;
import java.util.Iterator;
import java.util.NoSuchElementException;
@ -16,32 +15,32 @@ import java.util.NoSuchElementException;
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @author Mauricio S. Moura
* @
* @version $Revision: 1.4 $
* @version $Revision: 1.5 $
*/
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.getLength( array );
return index < array.length;
}
public Object next() {
if(!hasNext()) {
throw new NoSuchElementException();
}
return Array.get( array, index++ );
return array[ index++ ];
}
public void remove() {
@ -50,11 +49,11 @@ public class ArrayIterator implements Iterator {
// 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;
}

View File

@ -1,7 +1,7 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestArrayIterator.java,v 1.3 2001/07/14 23:33:26 craigmcc Exp $
* $Revision: 1.3 $
* $Date: 2001/07/14 23:33:26 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestArrayIterator.java,v 1.4 2001/08/23 10:50:01 jstrachan Exp $
* $Revision: 1.4 $
* $Date: 2001/08/23 10:50:01 $
*
* ====================================================================
*
@ -72,7 +72,7 @@ import java.util.NoSuchElementException;
*
* @author James Strachan
* @author Mauricio S. Moura
* @version $Id: TestArrayIterator.java,v 1.3 2001/07/14 23:33:26 craigmcc Exp $
* @version $Id: TestArrayIterator.java,v 1.4 2001/08/23 10:50:01 jstrachan Exp $
*/
public class TestArrayIterator extends TestObject {
@ -92,7 +92,7 @@ public class TestArrayIterator extends TestObject {
* Return a new, empty {@link Object} to used for testing.
*/
public Object makeObject() {
return new ArrayIterator(testArray);
return new ArrayIterator( (Object[]) testArray );
}
public void testIterator() {