commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jack, Paul" <>
Subject RE: [collections] Changing Iterators
Date Sat, 17 Aug 2002 20:15:32 GMT
> Now that the changes are made, I can explain them ;-)
> Thus, if code ran before it should still do so. Does this 
> need documenting ?

The three changes you made didn't affect released classes;
CollatingIterator, ListIteratorWrapper and IteratorChain are
new since 2.0.

So, the release notes should just indicate that they now exist.

The three new ones don't quite behave like the old ones but I
think this is fine.  Users who want consistent behaviors can use
IteratorUtils to ensure the preconditions.  Thanks Steve.

Some comments though:

1.  Can we please keep singletons as final public static fields?
IteratorUtils.EMPTY_ITERATOR would be in keeping with 
Collections.EMPTY_SET and Collections.EMPTY_MAP.  And generally
it makes it clear that they're singletons.  (Actually, the 
current implementation of emptyIterator() doesn't produce a 
singleton, which is a little wierd to me.)

2.  I'd like to see 

    Iterator IteratorUtils.asIterator(Enumeration)
    Enumeration IteratorUtils.asEnumeration(Iterator)

instead of

    Iterator IteratorUtils.enumerationIterator(Enumeration)
    Enumeration IteratorUtils.iteratorEnumeration(Iterator)

(a) the "as" prefix is in keeping with Arrays.asList, and is the 
recommended convention for adapter views.
(b) I think it's easier to understand.  Otherwise I'd find myself
constantly looking at the docs to remember which word comes first 
for the method I want.  

3.  Similarly, I'd like

    ListIterator toListIterator(Iterator i);

instead of 

    Iterator iteratorListIterator(Iterator i);

(Which actually should return a ListIterator instead of plain 

Again, "to" is the recommended prefix for transmutations.  

Also, do you think we should leave ComparatorUtils and IteratorUtils
where they are or move them into the subpackages?


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message