commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pwomack <pwom...@papermule.co.uk>
Subject [collections] bug in IteratorChain?
Date Mon, 01 Dec 2003 17:46:14 GMT
The following pseudo Junit:

         Integer a = new Integer(3);
         Integer b = new Integer(7);

         ArrayList empty = new ArrayList();
         IteratorChain ic = new IteratorChain();
         ic.addIterator(empty.iterator());
         ic.addIterator(new SingletonIterator(a));
         ic.addIterator(new SingletonIterator(b));

         int tot = 0;
         for(;ic.hasNext();) {
             Integer anInt = (Integer)ic.next();
             tot += anInt.intValue();
         }
         assertEquals(10, tot);

Fails. tot is actually 0.

I suspect the empty first Iterator somehow makes the whole
iteratorChain behave as if it's empty.

      BugBear


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


Mime
View raw message