commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rich Dougherty <>
Subject Re: [collections] Questions....
Date Wed, 20 Aug 2003 05:33:53 GMT
>So the question is do we really need SingletonIterator and such. If we 
>want to eliminate the number of methods or classes, then what about one 
>class for all of collections or iterators? I suppose the use of 
>singleton methods and classes is almost always to provide an object 
>matching a data type you want. Thus, we can have a class like
>class Singleton implements List, SortedSet, Bag, Iterator, ListIterator 
>Although it is usually bad practice to aggregate several different 
>functionalities into one class, in this case, it might be fine.
>Yes, this is in line with your proposal; we can use 
>SingletonListIterator for both Iterator and ListIterator. I think the 
>problem of this solution is users probably expect SingletonIterator 
>intuitively and might be puzzled why there is no such.

I don't know if such a class makes sense... The next() method should 
return its contents on the first call, but return null for all 
successive calls. Thus it could only be used as an Iterator once, which 
doesn't seem very useful to me.

Rich Dougherty

View raw message