commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@btopenworld.com
Subject Re: [collections] [patch] changes for ArrayListIterator was: Re: [collections] private member access in o.a.c.collections.iterators
Date Tue, 10 Dec 2002 10:45:32 GMT
Thanks for the patches. I will look at them in more detail later, however I do have a small
problem that I can see from your text.

IteratorUtils now has an unmodifiableListIterator(Iterator) method that wraps iterators to
make them unmodifiable. I would prefer to keep this as the only way to make an unmodifiable
iterator. 

Also, I am very uncomfortable with ArrayListIterator being a subclass of UnmodifiableArrayListIterator.
There is no 'is a' relationship here, and worse, if I declared a method to take in an UnmodifiableArrayListIterator
it would accept a modifiable one which would probably not be what I want.

Would it be possible for you to refactor to remove UnmodifiableArrayListIterator? Thanks ;-)

Stephen

>  from:    Neil O'Toole <neilotoole@users.sourceforge.net>
> - 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


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message