Jason Mehrens jason_mehrens at
Tue Mar 30 23:11:58 UTC 2010



I'm all for adding support for unmodifiableIterable, unmodifableNavigableMap, and unmodifableNavigableSet.  However, I think adding public access to such a iterator decorator goes against the guidelines of the collections design faq (4 and 5):



So following the guideline of never passing an Iterator around, that leaves you with the following:

1. Your custom container is backed by collection, use Collections.unmodifiableXXX(this.internal).iterator()

2. Your custom container is backed by an array, use Arrays.asList, followed by point 1.

3. Your custom container has specialized layout, you have to write an iterator with a remove implementation that removes or throws and the unmodifable one is easy to write.


Assuming that JDK had unmodifiableIterable decorator, is there is there a corner case that I'm not seeing or is the main reservation the extra method calls and creation of some well behaved garbage?


> Date: Tue, 30 Mar 2010 17:01:57 -0400
> Subject: Re: java.util.Pair
> From: scolebourne at
> To: core-libs-dev at
> (I´m writing from a slow connection in a national park in Chile)
> I meant a decortator for an iterator that wraps the original making it
> immutable.
> Stephen
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the core-libs-dev mailing list