commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neil O'Toole <neiloto...@users.sourceforge.net>
Subject [collections] [patch] changes for ArrayListIterator was: Re: [collections] private member access in o.a.c.collections.iterators
Date Tue, 10 Dec 2002 01:42:21 GMT
The attached zip includes the following new classes:

- UnmodifiableArrayListIterator: provides a ListIterator impl over an
array. Does not support ListIterator#set, #add, or #remove. Extends
ArrayIterator (which does not support #add or #remove either). 

- ArrayListIterator.java : Extends UnmodifiableArrayListIterator, and
supports #set.

- TestArrayListIterator.java : test cases, extends TestArrayIterator.

- TestArrayListIterator2.java : test cases, extends TestArrayIterator2.



And the following patches:

- ArrayIterator.patch : changes member access from private to
protected, and allows iteration over zero-length array sections.

- TestArrayIterator2.patch : replaces use of the ArrayIterator
constructor with a factory method, to allow subclassing by
TestArrayListIterator2. Also tests that zero-length iteration is
permitted (was prohibited).

- IteratorUtils.patch : added arrayListIterator(...) methods. Actually
they were already present but commented out, so it wasn't that much
work ;)

- TestAll.patch : included TestArrayListIterator and
TestArrayListIterator2 in test suite.


Enjoy ;)

- Neil


--- Stephen Colebourne <scolebourne@btopenworld.com> wrote:
> Go for it ;-)
> Stephen
> 
> ----- Original Message -----
> From: "Neil O'Toole" <neilotoole@users.sourceforge.net>
> To: "Jakarta Commons Developers List"
> <commons-dev@jakarta.apache.org>
> Sent: Friday, December 06, 2002 9:51 PM
> Subject: Re: [collections] private member access in
> o.a.c.collections.iterators
> 
> 
> >
> > I've prepared a patch for ArrayIterator, and the ArrayListIterator
> > class is ready to go, with associated test cases. However, there is
> > another issue with ArrayIterator. The ArrayIterator(Object array,
> int
> > start, int end) constructor has the following test:
> >
> >         if(end <= start) {
> >             throw new IllegalArgumentException(
> >
> > My understanding is that this should really be changed to:
> >
> >         if(end < start) {
> >
> > The current behaviour prohibits the creation of an iterator over a
> > zero-length section of array, even though this is a valid thing to
> do.
> > Unless there are objections, I will also include this change in the
> > patch. This will also require changes to TestArrayList, so I guess
> I
> > can create a patch for this as well.
> >
> > Any comments?
> >
> > - Neil

Mime
View raw message