commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Elkins <>
Subject Re: [PATCH][Collections] Add empty iterator to CollectionUtils
Date Thu, 22 Nov 2001 06:14:37 GMT
On Wed, Nov 21, 2001 at 11:58:07PM -0500, wrote:
> What's your view on making the EmptyIterator class a proper public class.
> Is there a strong reason for deciding that all EmptyIterators must be
> the same instance?
> It's probably just a style thing, but I wanted to check.

There are a few reasons:
  - It parallels the set theory notion that all empty sets are really the
    same empty set.
  - It parallels Collections.EMPTY_[LIST|MAP|SET].
  - Because it's immutable it's perfectly valid to return the same instance.
    (It also offers a minimal performance gain.)

Ultimately I guess it is a matter of style. Indeed, my local implementation
is a proper class; I took the opportunity of contributing it to the Commons
as an excuse for implementing it the right way (where "right" is justified
using the above reasons). :-)

Christopher Elkins

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

View raw message