I note from the spec that IteratorChain (amonst others)
throws an exception if it is empty;

Throws:
UnsupportedOperationException - if the IteratorChain does not contain at least one Iterator


This results in the following unfortunate behaviour; if I
transform this code:

for(Iterator ib = a.iterator(); ib.hasNext();) {
    ObjB b = (ObjB)ib.next();
    for(Iterator ic = b.iterator(); ic.hasNext();) {
        ObjC c = (ObjC)ic.next();
        // do something with a 'C'
    }
}

into this form:

IteratorChain allC = new IteratorChain();
for(Iterator ib = a.iterator(); ib.hasNext();) {
    ObjB b = (ObjB)ib.next();
    allC.addIterator(b.iterator());
}

for(;allC.hasNext();) {
   ObjC c = (ObjC)allC.next();
   // do something with a 'C'
}

If the original 'a' is empty, the second version throws an Exception,
(since allC has no Iterators) whereas the first version correctly
does nothing.

I assert that the second version should be as equivalent
as possible to this first; in short I believe that
the Exception should not be thrown.

BugBear


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to