java.util.Pair
Jason Mehrens
jason_mehrens at hotmail.com
Tue Mar 30 23:11:58 UTC 2010
Stephen,
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):
http://java.sun.com/javase/6/docs/technotes/guides/collections/designfaq.html#8
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?
Jason
> Date: Tue, 30 Mar 2010 17:01:57 -0400
> Subject: Re: java.util.Pair
> From: scolebourne at joda.org
> To: core-libs-dev at openjdk.java.net
>
> (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.
http://clk.atdmt.com/GBL/go/210850552/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20100330/5700af6e/attachment.html>
More information about the core-libs-dev
mailing list