pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dirk Moebius (JIRA)" <j...@apache.org>
Subject [jira] Commented: (PIVOT-484) ArrayList.ItemIterator.remove() advances the iterator
Date Thu, 29 Apr 2010 10:23:54 GMT

    [ https://issues.apache.org/jira/browse/PIVOT-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12862152#action_12862152
] 

Dirk Moebius commented on PIVOT-484:
------------------------------------

Verified successful. Thanks!

> ArrayList.ItemIterator.remove() advances the iterator
> -----------------------------------------------------
>
>                 Key: PIVOT-484
>                 URL: https://issues.apache.org/jira/browse/PIVOT-484
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-collections
>    Affects Versions: 1.4, 1.5
>            Reporter: Dirk Moebius
>             Fix For: 1.5
>
>
> The remove() method of ArrayListItemIterator doesn't move the pointer back one item.
After remove() your only option is to call next(), but the implementation of ArrayListItemIterator
moves to _second next_ item instead of the item which comes after the removed one. So it is
impossible to iterate to the item which comes immediately after the removed item.
> The following code illustrates this (run with "-ea"):
> public class ArrayListTest {
>     public static void main(String[] args) {
>         java.util.ArrayList<String> javaList = new java.util.ArrayList<String>();
>         javaList.add("first");
>         javaList.add("second");
>         javaList.add("third");
>         Iterator<String> iterator = javaList.iterator();
>         String s = iterator.next();
>         assert s.equals("first");
>         iterator.remove();
>         s = iterator.next();
>         System.out.println("Java ArrayList: next is: " + s);
>         assert s.equals("second");
>         org.apache.pivot.collections.ArrayList<String> pivotList = new org.apache.pivot.collections.ArrayList<String>();
>         pivotList.add("first");
>         pivotList.add("second");
>         pivotList.add("third");
>         iterator = pivotList.iterator();
>         s = iterator.next();
>         assert s.equals("first");
>         iterator.remove();
>         s = iterator.next();
>         System.out.println("Pivot ArrayList: next is: " + s);
>         assert s.equals("second"); // fail, got: "third"
>     }
> }
> I didn't check the other Iterator implementations. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message