commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 38341] New: - IteratorChain skips over elements in iterator
Date Sat, 21 Jan 2006 01:12:27 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38341>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38341

           Summary: IteratorChain skips over elements in iterator
           Product: Commons
           Version: 3.1
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: major
          Priority: P2
         Component: Collections
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: jo@jogiles.co.nz


Hi there,
When using the IteratorChain class to add multiple iterators, it appears that
using itChain.hasNext() and itChain.next() skips a number of elements in the
iterator at each step.

Given a single iterator of 7 elements, and using the following code:

private IteratorChain buildIterator() {
// this iterator contains the children of the current object only
Iterator it = getChildren(p);
		
// we use an IteratorChain to add multiple iterators together without the
overhead of copying
IteratorChain itChain = new IteratorChain(it);

return itChain;
}

and then simply
IteratorChain it = treeModel.getAllTreeNodes(obj);
	
// FIXME this only prints one or two of the results, which is a bug!
while (it.hasNext())
    System.out.println(": " + it.next().getClass());

I put in 7 elements, but only get 2 out - the 2nd and the last elements. It
appears that through my debugging that the nextClause variable is updated even
when the hasNext() function is called.

Also, if I put 7 system.out.println statements, all elements are printed as normal.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


Mime
View raw message