You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Phil Steitz <ph...@steitz.com> on 2003/09/28 06:49:49 UTC

Re:[collections] Bug in previousIndex() in ArrayListIterator, ObjectArrayListIterator?

Sorry. Forgot the prefix...

Phil Steitz wrote:
> If an ArrayListIterator or ObjectArrayListIterator is constructed from 
> an array with an offset, the internal index is initialized and 
> maintained relative to the array offset. For example, if we create a 
> ListIterator like so:
> 
> Object[] objArray = {"a", "b", "c", "d"};
> ListIterator iterator = IteratorUtils.arrayListIterator(objArray, 3);
> 
> iterator.previousIndex() returns 2 if called immediatly. On the other 
> hand, iterator.hasPrevious() returns false in this case.  This seems 
> inconsistent with the ListIterator API.
> 
> I think that when the ListIterator is constructed, previousIndex should 
> return -1 and it should be maintained relative the the "visible" portion 
> of the underlying array, so that the ListIterator acts just like a 
> ListIterator formed using a copy of the subarray.  Any reason not to 
> change this?
> 
> Phil
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 




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


Re: [collections] Bug in previousIndex() in ArrayListIterator, ObjectArrayListIterator?

Posted by Phil Steitz <ph...@steitz.com>.
Stephen Colebourne wrote:
> Basically, anything that people might have relied on (public/protected) is a
> backwards compatable issue. However, if it is a bug fix, then the change can
> be justified.

I made the change without modifying ArrayIterator, so there should be no 
compatability issue.

> 
> Your changes sound OK by description, but I haven't looked at the code. My
> view is that if List.listIterator(3).previousIndex() == -1 then so should
> we.
> 
> Stephen
> 
> 
> ----- Original Message -----
> From: "Phil Steitz" <ph...@steitz.com>
> 
>>I just noticed that ArrayListIterator is marked as @since 2.2. This
>>should be 3.0, right (i.e. 2.2 was never released)?
>>
>>One way to fix the problem (assuming that others agree that it is a
>>"problem" ;-) involves changing the way that ArrayIterator (which is
>>@since 1.0) internally manages its protected index field.  The changes
>>would result in no difference in behavior for ArrayIterator's public
>>methods, but since index is protected, users who have subclassed
>>ArrayIterator could conceivably be impacted. What is the policy on these
>>kinds of changes?  Would this count as an "incompatible change"?
>>
>>Phil
>>
>>
>>Phil Steitz wrote:
>>
>>>Sorry. Forgot the prefix...
>>>
>>>Phil Steitz wrote:
>>>
>>>
>>>>If an ArrayListIterator or ObjectArrayListIterator is constructed from
>>>>an array with an offset, the internal index is initialized and
>>>>maintained relative to the array offset. For example, if we create a
>>>>ListIterator like so:
>>>>
>>>>Object[] objArray = {"a", "b", "c", "d"};
>>>>ListIterator iterator = IteratorUtils.arrayListIterator(objArray, 3);
>>>>
>>>>iterator.previousIndex() returns 2 if called immediatly. On the other
>>>>hand, iterator.hasPrevious() returns false in this case.  This seems
>>>>inconsistent with the ListIterator API.
>>>>
>>>>I think that when the ListIterator is constructed, previousIndex
>>>>should return -1 and it should be maintained relative the the
>>>>"visible" portion of the underlying array, so that the ListIterator
>>>>acts just like a ListIterator formed using a copy of the subarray.
>>>>Any reason not to change this?
>>>>
>>>>Phil
>>>>
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 




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


Re: [collections] Bug in previousIndex() in ArrayListIterator, ObjectArrayListIterator?

Posted by Phil Steitz <ph...@steitz.com>.
Stephen Colebourne wrote:
> Basically, anything that people might have relied on (public/protected) is a
> backwards compatable issue. However, if it is a bug fix, then the change can
> be justified.

I made the change without modifying ArrayIterator, so there should be no 
compatability issue.

> 
> Your changes sound OK by description, but I haven't looked at the code. My
> view is that if List.listIterator(3).previousIndex() == -1 then so should
> we.
> 
> Stephen
> 
> 
> ----- Original Message -----
> From: "Phil Steitz" <ph...@steitz.com>
> 
>>I just noticed that ArrayListIterator is marked as @since 2.2. This
>>should be 3.0, right (i.e. 2.2 was never released)?
>>
>>One way to fix the problem (assuming that others agree that it is a
>>"problem" ;-) involves changing the way that ArrayIterator (which is
>>@since 1.0) internally manages its protected index field.  The changes
>>would result in no difference in behavior for ArrayIterator's public
>>methods, but since index is protected, users who have subclassed
>>ArrayIterator could conceivably be impacted. What is the policy on these
>>kinds of changes?  Would this count as an "incompatible change"?
>>
>>Phil
>>
>>
>>Phil Steitz wrote:
>>
>>>Sorry. Forgot the prefix...
>>>
>>>Phil Steitz wrote:
>>>
>>>
>>>>If an ArrayListIterator or ObjectArrayListIterator is constructed from
>>>>an array with an offset, the internal index is initialized and
>>>>maintained relative to the array offset. For example, if we create a
>>>>ListIterator like so:
>>>>
>>>>Object[] objArray = {"a", "b", "c", "d"};
>>>>ListIterator iterator = IteratorUtils.arrayListIterator(objArray, 3);
>>>>
>>>>iterator.previousIndex() returns 2 if called immediatly. On the other
>>>>hand, iterator.hasPrevious() returns false in this case.  This seems
>>>>inconsistent with the ListIterator API.
>>>>
>>>>I think that when the ListIterator is constructed, previousIndex
>>>>should return -1 and it should be maintained relative the the
>>>>"visible" portion of the underlying array, so that the ListIterator
>>>>acts just like a ListIterator formed using a copy of the subarray.
>>>>Any reason not to change this?
>>>>
>>>>Phil
>>>>
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 




Re: [collections] Bug in previousIndex() in ArrayListIterator, ObjectArrayListIterator?

Posted by Stephen Colebourne <sc...@btopenworld.com>.
Basically, anything that people might have relied on (public/protected) is a
backwards compatable issue. However, if it is a bug fix, then the change can
be justified.

Your changes sound OK by description, but I haven't looked at the code. My
view is that if List.listIterator(3).previousIndex() == -1 then so should
we.

Stephen


----- Original Message -----
From: "Phil Steitz" <ph...@steitz.com>
> I just noticed that ArrayListIterator is marked as @since 2.2. This
> should be 3.0, right (i.e. 2.2 was never released)?
>
> One way to fix the problem (assuming that others agree that it is a
> "problem" ;-) involves changing the way that ArrayIterator (which is
> @since 1.0) internally manages its protected index field.  The changes
> would result in no difference in behavior for ArrayIterator's public
> methods, but since index is protected, users who have subclassed
> ArrayIterator could conceivably be impacted. What is the policy on these
> kinds of changes?  Would this count as an "incompatible change"?
>
> Phil
>
>
> Phil Steitz wrote:
> > Sorry. Forgot the prefix...
> >
> > Phil Steitz wrote:
> >
> >> If an ArrayListIterator or ObjectArrayListIterator is constructed from
> >> an array with an offset, the internal index is initialized and
> >> maintained relative to the array offset. For example, if we create a
> >> ListIterator like so:
> >>
> >> Object[] objArray = {"a", "b", "c", "d"};
> >> ListIterator iterator = IteratorUtils.arrayListIterator(objArray, 3);
> >>
> >> iterator.previousIndex() returns 2 if called immediatly. On the other
> >> hand, iterator.hasPrevious() returns false in this case.  This seems
> >> inconsistent with the ListIterator API.
> >>
> >> I think that when the ListIterator is constructed, previousIndex
> >> should return -1 and it should be maintained relative the the
> >> "visible" portion of the underlying array, so that the ListIterator
> >> acts just like a ListIterator formed using a copy of the subarray.
> >> Any reason not to change this?
> >>
> >> Phil
> >>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


Re: [collections] Bug in previousIndex() in ArrayListIterator, ObjectArrayListIterator?

Posted by Stephen Colebourne <sc...@btopenworld.com>.
Basically, anything that people might have relied on (public/protected) is a
backwards compatable issue. However, if it is a bug fix, then the change can
be justified.

Your changes sound OK by description, but I haven't looked at the code. My
view is that if List.listIterator(3).previousIndex() == -1 then so should
we.

Stephen


----- Original Message -----
From: "Phil Steitz" <ph...@steitz.com>
> I just noticed that ArrayListIterator is marked as @since 2.2. This
> should be 3.0, right (i.e. 2.2 was never released)?
>
> One way to fix the problem (assuming that others agree that it is a
> "problem" ;-) involves changing the way that ArrayIterator (which is
> @since 1.0) internally manages its protected index field.  The changes
> would result in no difference in behavior for ArrayIterator's public
> methods, but since index is protected, users who have subclassed
> ArrayIterator could conceivably be impacted. What is the policy on these
> kinds of changes?  Would this count as an "incompatible change"?
>
> Phil
>
>
> Phil Steitz wrote:
> > Sorry. Forgot the prefix...
> >
> > Phil Steitz wrote:
> >
> >> If an ArrayListIterator or ObjectArrayListIterator is constructed from
> >> an array with an offset, the internal index is initialized and
> >> maintained relative to the array offset. For example, if we create a
> >> ListIterator like so:
> >>
> >> Object[] objArray = {"a", "b", "c", "d"};
> >> ListIterator iterator = IteratorUtils.arrayListIterator(objArray, 3);
> >>
> >> iterator.previousIndex() returns 2 if called immediatly. On the other
> >> hand, iterator.hasPrevious() returns false in this case.  This seems
> >> inconsistent with the ListIterator API.
> >>
> >> I think that when the ListIterator is constructed, previousIndex
> >> should return -1 and it should be maintained relative the the
> >> "visible" portion of the underlying array, so that the ListIterator
> >> acts just like a ListIterator formed using a copy of the subarray.
> >> Any reason not to change this?
> >>
> >> Phil
> >>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


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


Re: [collections] Bug in previousIndex() in ArrayListIterator, ObjectArrayListIterator?

Posted by Phil Steitz <ph...@steitz.com>.
I just noticed that ArrayListIterator is marked as @since 2.2. This 
should be 3.0, right (i.e. 2.2 was never released)?

One way to fix the problem (assuming that others agree that it is a 
"problem" ;-) involves changing the way that ArrayIterator (which is 
@since 1.0) internally manages its protected index field.  The changes 
would result in no difference in behavior for ArrayIterator's public 
methods, but since index is protected, users who have subclassed 
ArrayIterator could conceivably be impacted. What is the policy on these 
kinds of changes?  Would this count as an "incompatible change"?

Phil


Phil Steitz wrote:
> Sorry. Forgot the prefix...
> 
> Phil Steitz wrote:
> 
>> If an ArrayListIterator or ObjectArrayListIterator is constructed from 
>> an array with an offset, the internal index is initialized and 
>> maintained relative to the array offset. For example, if we create a 
>> ListIterator like so:
>>
>> Object[] objArray = {"a", "b", "c", "d"};
>> ListIterator iterator = IteratorUtils.arrayListIterator(objArray, 3);
>>
>> iterator.previousIndex() returns 2 if called immediatly. On the other 
>> hand, iterator.hasPrevious() returns false in this case.  This seems 
>> inconsistent with the ListIterator API.
>>
>> I think that when the ListIterator is constructed, previousIndex 
>> should return -1 and it should be maintained relative the the 
>> "visible" portion of the underlying array, so that the ListIterator 
>> acts just like a ListIterator formed using a copy of the subarray.  
>> Any reason not to change this?
>>
>> Phil
>>



Re: [collections] Bug in previousIndex() in ArrayListIterator, ObjectArrayListIterator?

Posted by Phil Steitz <ph...@steitz.com>.
I just noticed that ArrayListIterator is marked as @since 2.2. This 
should be 3.0, right (i.e. 2.2 was never released)?

One way to fix the problem (assuming that others agree that it is a 
"problem" ;-) involves changing the way that ArrayIterator (which is 
@since 1.0) internally manages its protected index field.  The changes 
would result in no difference in behavior for ArrayIterator's public 
methods, but since index is protected, users who have subclassed 
ArrayIterator could conceivably be impacted. What is the policy on these 
kinds of changes?  Would this count as an "incompatible change"?

Phil


Phil Steitz wrote:
> Sorry. Forgot the prefix...
> 
> Phil Steitz wrote:
> 
>> If an ArrayListIterator or ObjectArrayListIterator is constructed from 
>> an array with an offset, the internal index is initialized and 
>> maintained relative to the array offset. For example, if we create a 
>> ListIterator like so:
>>
>> Object[] objArray = {"a", "b", "c", "d"};
>> ListIterator iterator = IteratorUtils.arrayListIterator(objArray, 3);
>>
>> iterator.previousIndex() returns 2 if called immediatly. On the other 
>> hand, iterator.hasPrevious() returns false in this case.  This seems 
>> inconsistent with the ListIterator API.
>>
>> I think that when the ListIterator is constructed, previousIndex 
>> should return -1 and it should be maintained relative the the 
>> "visible" portion of the underlying array, so that the ListIterator 
>> acts just like a ListIterator formed using a copy of the subarray.  
>> Any reason not to change this?
>>
>> Phil
>>



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